linking combo box problem

campo88

Registered User.
Local time
Today, 07:59
Joined
Nov 20, 2009
Messages
46
Hi

I have two combo boxes. The first combo box is used to select a category. The second combo box should then produce a list of items according to the category. I have done this in the same manner as the video on the below link using access 2007:

http://datapigtechnologies.com/flashfiles/combobox2.html


Frustratingly when changing the first combo box, the second combo box sometimes does not change.

I use the second combo box to populate into a field in a table. I am not sure if this may cause the problem?

Can any1 help please?
 
I am pretty sure I now know why it is not working, but still need your help to solve the problem.

I believe it may be because my combo boxes is in a tab and as I am using code:

Me.

this is therefore not referring to the combo box correctly. Am I right? How can I correct it?
 
Are the two combo's on the same tab? Is there a subform involved?
 
Hi

The two combos on the same tab. Both on page 2 of the tab control.

No subform.

The problem is when changing combo 1, it does not requery combo 2.
 
What is the event/s you are using to requery the second combo, and what is the code you are using?
 
The code used to requery the event.

Code:
Private Sub combobox1_AfterUpdate()
Me.combobox2 = Null
Me.combobox2.Requery
Me.combobox2 = Me.combobox2.ItemData(0)
End Sub
In the row source of properties of combobo2 I have the below criteria in my query:

[forms]![option selector]![combobox1]


My code works perfectly when done on page 1 of the tab control. However it does not requery when on page 2 of the tab control. :(
 
JPaulo - The database is not quite what i want because i need that in page 2 of a tab control.

Can you do this and send to me? Also please send so that I can see the coding.

Cheers
 
All you need in your After Update event is;

Code:
Me.combobox2.Requery

Your current code is first setting combobox2 to Null then re-querying it, then setting it to combobox2.ItemData(0) :confused:

You will also need to put the Requery command in the form's OnCurrent Event, to ensure that the combos work correctly when you change records.
 
You will also need to put the Requery command in the form's OnCurrent Event, to ensure that the combos work correctly when you change records.

How do I do this?
 
With the form in design view click in the small square at the junction of the vertical and horizontal rulers a small black square should appear in within that square, indicating that the property sheet is now showing form properties. Now click on the events Tab, the ONCurrent event is the first in the list. Put the code;
Code:
Me.combobox2.Requery
into this event.
 
Have now got this code for after update and oncurrent, however still not working for my comboboxes on page 2 of my tab control.

hmmm frustrating. Any ideas?
 

Users who are viewing this thread

Back
Top Bottom