Form needs refresh before combo box shows correct data

PTRACER

Registered User.
Local time
Today, 13:48
Joined
Feb 18, 2008
Messages
48
I have a combo box on a Repair form, which is bound to "ComputerID" and uses a query as its row source. The query contains the values of Computer.ComputerID (the ID of a computer), CompMan.Manufacturer (the manufacturer of the computer) and Computer.Model (the computer's model/type).

The problem is that this lists every computer owned by every customer, although it does select the one for the current Repair. When I add "CustomerID" to the query and point it to Forms!Repair!CustomerID, the combo box defaults to the value of ComputerID = 1, unless I press Refresh and then it selects all the computers relating to the current customer.

Any idea why this would be?
 
What is it you want to select in the combo box? Are you trying to use it as a filter to find records?
 
You might need some simple VB Code for this one. If you're dealing with multiple tables on a form, and need a drop-down to work properly, I've found that adding your SQL query to the "On Focus" event of the combo-box is the best bet for loading data after the form is loaded.

This also works great for using multiple combo boxes that run off of eachother.
 
What is it you want to select in the combo box? Are you trying to use it as a filter to find records?

Yep, basically.

I create a new customer on the Customer form and add the details of their computer on a subform. Then I click "New Repair", and it opens the Repair form...I've set it up so when you create a new repair, it sets the CustomerID and the ComputerID in two hidden text boxes.

I'm trying to use the combo box to only select the CustomerID that is on the current repair, hence I point it at the hidden text box.
 
HI,

I use this sort of thing a lot.

Set the datasource of the combobox to a query and in the query design grid set the criteria so that the customerid equals the customerid on the form the combo box is on. Use the expression builder to get the syntax just right when referencing a field on a form it's much easier that way.

In the on click event of the combo box add an event procedure and put in the line

"your combo box name".requery

This means that when you click the combo box, the datasource is requeired and only those records that relate to the criteria are shown on the list.

Hope this helps, but if you need any more detail let me know.

Sue
 

Users who are viewing this thread

Back
Top Bottom