Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box in Query Criteria 1

Status
Not open for further replies.

WatDisDo

Programmer
Jul 7, 2001
3
GB
Hi y'all

I am running a select/where query in a combo box that uses the contents of another combo box in the criteria to provide the input for the where clause. (e.g. [Forms]![ADP Entry]![cboBuyerName]). I also want to requery (via macro) on either the lostfocus event of the source combo, or the gotfocus of the target combo. The problem is that it ain't working. If I use a textbox, it works a treat (e.g. [Forms]![ADP Entry]![txtTemp]) but using the combo box as a source fails.

Any ideas/solutions gratefully received. Thanx in advance.

Malcolm.
 
Hi Malcolm,

Let's see if I understand your problem.

I have a form with two combo boxes. The "source" combo box[cboOwner] is based on a table [tblOwners]. The "target" combo box is based on a qry which lists all the properties owned by the person selected in the first combo box. When you change the owner in the source combo box you want the target combo box to refresh showing only the property owned by that person, correct?

Create a macro that clears the value in the target combo box and then re-runs the query that's used as it's row source. Assign this macro to the After Update event of the "source" combo box.

macRequeryComboBox


Action: SetValue
Item: [Forms]![YourFormName]![cboYourTargetComboBoxName]
Epression: Null

Action: Requery
Control Name: cboYourTargetComboBoxName

Save the macro and assign it to the After Update event of your source combo box.

HTH


 
Hi SKO,

Yes, you understand my problem, but I've managed to fix it. The approach you suggested was pretty much what I had done, but with the source cbo based on a select query, embedded in the control. The target cbo was also based on a select query embedded in the target cbo control. I took the target query out of the control, named it and called it via a macro and, presto!!, it works. That'll do for me.

Many thanks for your help and response.

Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top