Parameter Query

uplink600

Registered User.
Local time
Today, 04:44
Joined
Mar 18, 2004
Messages
69
I have set up a dialog box/form to act as a custom query builder. The user can enter various search information using a selection of textboxes and combos.

The query design as as follows.

In the field section I have the following

[SalesPerson]=[Forms]![Search]![cboSalesPerson] Or [Forms]![Search]![cboSalesPerson] Is Null

The SQL is

SELECT Main.RecordNumber
FROM Main
WHERE ((([SalesPerson]=Forms!Search!cboSalesPerson Or Forms!Search!cboSalesPerson Is Null)=True))
ORDER BY Main.RecordNumber;

Criteria is set as TRUE

This is just one part of the query, I won't set the other fields up until I get this working. On the form the user will select the sales person name from cboSalesPerson and then click the cmdSearch button. cmdSearch runs a macro which opens the query, currently in datasheet view, but later it will be a form or report view.

The trouble is this won't work at present. If I run the query from it's design view it ask's for the parameter and works fine. It just won't work when run from the cmdSeach button on the custom search form. It seems the value in the combo is not passed to the query.

Any ideas what might be wrong please.

Thanks

VC
 
You will need to setup in Visual Basics editor a Serach_Click() Sub set the focus of the text box you want to have int he search by Textbox.SetFocus then make a DoCmd.OpenQuery "Query1" If you want to make a Form that is based on the Query then just change the DoCmd to DoCmd.OpenForm "Formmadefromquery1"
 

Users who are viewing this thread

Back
Top Bottom