Question parameter value

jerry28ph

jerry
Local time
Today, 14:36
Joined
Nov 16, 2008
Messages
141
I have a combo box and 2 text boxes in my main form to enter my criteria for my query, every time I run the main form (frmLog), instead of showing it, a small screen will appear to "Enter Parameter Value", how can I use my main form to enter my criteria?

Please i need you help.
Thank you.
 
You can use the query builder to add the combo and textboxes to the criteria of your query. Simply right mouse click over the Criteria field in the query window and select Build.

You would end with a SQL statement along the lines of

Code:
SELECT TableOne.Field1, TableOne.Field2, TableOne.Field3
FROM TableOne
WHERE TableOne.Field1=[Forms]![frmLog]![cboField1] AND TableOne.Field2=[Forms]![frmLog]![txtField2] AND TableOne.Field3=[Forms]![frmLog]![txtField3]

I will usually add some extra features depending on what data I expect, so that if I want to use a wildcard for a text field I use:
Code:
TableOne.Field3 LIKE "*" & [Forms]![frmLog]![txtField3] & "*"

If a combobox also contains an "All" option, which should display all values without filtering, it gets a little harder, but basically you need to add an IIF statement to your criteria so that when 'All' is selected, return all records otherwise filter based on the combobox value.
Create a new field for the select query:
Code:
IIf([Forms]![frmLog]![cboField1]="All","All",TableOne.Field1)
In the Criteria for the field:
Code:
IIf([Forms]![frmLog]![cboField1]="All","All",[Forms]![frmLog]![cboField1])
 
Enter Parameter Value usually indicates a spelling mistake or an incomplete reference to your form object.
 
it is suggested to post your source code , otherwise all of us are only guessing where is the problem.
 

Users who are viewing this thread

Back
Top Bottom