Parameter in Field Row

LadyDi

Registered User.
Local time
Today, 12:22
Joined
Mar 29, 2007
Messages
894
Is it possible to have a parameter in the field row of a query? That way, the user could select the field they want to query against without going into the design view of the query.
 
No, not easily.
Another approach may be to create some named(saved) queries that do SELECTs on specific fields. Then put the names or the "purpose" of those queries ina Combo box, and let the user Run the named query. You could still have a parameter for the "Value"/constraint.
 
I'm not sure what you are asking here. If you are asking to change the fields selected I will go with jdraw's answer, but if you mean can you vary the field on which you apply criteria then I think the answer is yes. All you need to do is have a form with a textbox or combo for all of the potential fields to be queried.

Then

Where (field1= forms!formname!txtbox1 or forms!formname!txtbox1 is null)
And (field2=forms!formname!txtbox2 or forms!formname!txtbox2 Is null)
And etc

Text boxes or combos not selected and thus returning null will not affect the selection

Brian
 
That is what I want to do - vary the field on which to apply the criteria.

I'm afraid, I'm a little unsure what to do though. I added a combo box containing all the available "buckets" to an existing form. Then I tried to add it to my query, but can't get it to run. The user will only need to apply criteria to one bucket, so I only added one combo box. What am I doing wrong?

Code:
SELECT WOWData.*
FROM WOWData
WHERE (((WOWData.WeekEndingDate) Between [StartDate] And [EndDate]) AND ((WOWData.Customer)=[Customer Name]) AND ((WOWData.([Forms]![frmMain]![Buckets])>[Criteria]));
 
I am sorry but I did not understand your reply, I don't understand "buckets".

Where did my idea of having one textbox or combo per potential criterial field fail, it is pretty standard query by form technique. The Is Null means that no criteria is applied to that field and the filtering is done on fields that do have criteria.

Brian
 
I apologize for the confusion. "Buckets" is the name for the field that I added to my form. A "bucket" is how my manager groups the service calls.

I'm afraid, I misunderstood what you had suggested originally. I thought I needed a combo box for how many fields would have criteria on them. Since the criteria will only be on one field, I thought I just needed one box. I realize now, that I need a box for every field that could have criteria in it. The combo box doesn't name the field, but it lists the criteria. The only excuse I have, is that yesterday was a really long day for me. I think my brain was fried by the time I got back to this project. :o

I think I understand now. Again, I apologize for the confusion. Thank you very much for your assistance.
 
Okay, I'm still having a little trouble with this. I added a text box for every field that might have the criteria in it. Then I added it to my query. However, I think because I want my criteria to be anything greater than a certain number, my query won't run. Here is my query with one of the new fields listed. How can I get this to handle greater than values? I tried typing >3 in the field, and I tried putting the > in the query and just the number in the text field. Neither one is working.

Code:
SELECT WOWData.*
FROM WOWData
WHERE (((WOWData.WeekEndingDate) Between [StartDate] And [EndDate]) AND ((WOWData.Customer) Like [Forms]![frmMain]![CustomerName]) AND ((WOWData.NoteDispenser)>([Forms]![frmMain]![NoteDispenser] Or [Forms]![frmMain]![NoteDispenser] Is Null)));
 
I cant see why that SQL would not work. Are you sure about which part of the Where clause is causing the problem. No offence intended but are you sure that there is data between the dates for the customer? :)

Brian
 
How are you running the query?
Have you tried doing a debug.print with your SQL to see the rendering that is being done?
 
Thank you for all your help. I figured out what my problem was. The combo box I was using for the Customer Name was not return the value I thought it was (it returned the Customer Number instead of the Name). I adjusted that and now everything works great.
 

Users who are viewing this thread

Back
Top Bottom