The right way to make a query by Form

odun

Registered User.
Local time
Yesterday, 19:47
Joined
Apr 24, 2005
Messages
108
Hello,

I have a query by form named QBF_Form, I use it to help users query a form without having to open the query directly. A query, Cert, is based on this form using expressions like:
Like Forms!QBF_Form!Sales & "*" Or Forms!QBF_Form!Sales Is Null

This Cert query is a source for a form called Manage. I have a macro to open the "Manage" form, run the Cert query, and close the query . Everything works fine when I do this.

But when I click on the Manage form directly, I get this: Enter Parameter Value:
Forms!QBF_Form!Sales

How can I prevent this from happening? How can I change the logic?

Thanks for your help again!
 
Last edited:
You should try the following code in your query:

Like IIF (Forms!QBF_Form!Sales)="", "*", "*" & Forms!QBF_Form!Sales & "*"

where if the value of the Forms!QBF_Form!Sales value = "" ( nothing ) then all the values are returned otherwise only the values meeting the Forms!QBF_Form!Sales criteria are returned.
 
Hi MstCyr
I am getting an error: the expression you entered has a wrong number of arguments, do you know why?
 
odun said:
Hi MstCyr
I am getting an error: the expression you entered has a wrong number of arguments, do you know why?

Hi Odun

I've just double checked what I sent you and it is ok. Here's an actual clip from an application that works perfectly:

Like IIf([Forms]![FindGuest]![txtWOrkerID]="","*","*" & [Forms]![FindGuest]![txtWOrkerID] & "*"

... or if you prefer send me the code you have at: stcyrm@aol.com

Best regards

Maurice St-Cyr
 
Hi Maurice,

When I used the following in my query in design view
Like IIf([Forms]![QBF_Form]![Sales]="","*","*" & [Forms]![QBF_Form]![Sales] & "*")
Notice the bracket at the end, I didn't get the error, "the expression you entered has a wrong number of arguments" anymore.

But when I tried to open my other form, Manage, this form feeds off the query I am working on, I still get the "Enter Parameter Value:
Forms!QBF_Form!Sales" error

Should I be using the:
Like IIf([Forms]![QBF_Form]![Sales]="","*","*" & [Forms]![QBF_Form]![Sales] & "*")

in design view or as an sql? I am currently using it in my query design view.

I don't currently have a code for this query, do I need a code to make it work? How do I set up the code?
 
>Should I be using the:
>Like IIf([Forms]![QBF_Form]![Sales]="","*","*" & [Forms]![QBF_Form]!>[Sales] & "*")
>in design view or as an sql? I am currently using it in my query design view.
>I don't currently have a code for this query, do I need a code to make it >work? How do I set up the code?

The formula is setup in the query design where you reference the form QBF_Form and the field sales.

Maurice
 
Hi Maurice,

Very grateful for your help. There must be something wrong with how I have set up my forms and query.

If you don't mind, as you offered, I will send a zip file of my db to your email and also provide an explanation on the problem I am facing.
Thanks again!
 
Thanks for your help, I appreciate it.

Attached is my DB.

The Q1T1Certificates query is based on the QBF_Form
The Manage form is based on the Q1T1Certificates query.

The QBF_Form helps the user to query the table without having to open the Q1T1Certificates query.

I have a macro, M1T1, that on clicking the QBF_Form, the macro opens the Manage Form, takes the information on the QBF_Form and runs the Q1T1Certificates query.

When I click on the QBF_Form, everything works perfectly.

But when I click on the Manage Form or the Q1T1 Certificaes query, I get this error:
Enter Parameter Value:
Forms!QBF_Form!Sales_org


even after changing the query design view to this for example:
Like IIf([Forms]![QBF_Form]![Sales_org]="","*","*" & [Forms]![QBF_Form]![Sales_org] & "*")

Please steer me in the right direction as to what I am doing wrong and how to work around this.

Thanks,
 

Attachments

Users who are viewing this thread

Back
Top Bottom