Linked combos not working

C

chris.edwards20

I have a form with a tabbed area in the lower part to accommodate
different categories of data. One tab has two combos cboJobGroup and
cboJobSubgroup. The rowsource property in cboJobSubgroup includes
reference to the value of cboJobGroup so that only appropriate values
for the Job Group are offered.

I am using the following code to ensure that only valid combinations
are chosen

Private Sub cboJobGroup_Dirty(Cancel As Integer)
'clear Job subgroup if job group is changed
Me!cboJobSubgroup.Value = Null
End Sub

Private Sub cboJobGroup_AfterUpdate()
'requeries subgroup combo to update the rowsource property with
the value entered for the JobGroup in this combo
Me!cboJobSubgroup.Requery
End Sub

But it doesn't work (although I think it did when I originally set it
up). To double check that I hadn't made some error in the code I added
a temporary command button on the tab which does the same things as
the above

Private Sub Command137_Click()
Me!cboJobSubgroup.Value = Null
Me!cboJobSubgroup.Requery
End Sub

Clicking it does have the expected effects. It would appear that the
AfterUpdate and the Dirty events are not occuring as expected as the
code attached to these does not appear to be run. I can't see why this
is - has anyone got any light to throw on the problem?
Chris
 
C

chris.edwards20

I have a form with a tabbed area in the lower part to accommodate
different categories of data. One tab has two combos cboJobGroup and
cboJobSubgroup. The rowsource property in cboJobSubgroup includes
reference to the value of cboJobGroup so that only appropriate values
for the Job Group are offered.

I am using the following code to ensure that only valid combinations
are chosen

Private Sub cboJobGroup_Dirty(Cancel As Integer)
    'clear Job subgroup if job group is changed
    Me!cboJobSubgroup.Value = Null
End Sub

Private Sub cboJobGroup_AfterUpdate()
    'requeries subgroup combo to update the rowsource property with
the value entered for the JobGroup in this combo
    Me!cboJobSubgroup.Requery
End Sub

But it doesn't work (although I think it did when I originally set it
up). To double check that I hadn't made some error in the code I added
a temporary command button on the tab which does the same things as
the above

Private Sub Command137_Click()
   Me!cboJobSubgroup.Value = Null
   Me!cboJobSubgroup.Requery
End Sub

Clicking it does have the expected effects. It would appear that the
AfterUpdate and the Dirty events are not occuring as expected as the
code attached to these does not appear to be run. I can't see why this
is - has anyone got any light to throw on the problem?
Chris

Since posting I have discovered that the property sheet for
cboJobGroup did not have [Event Procedure] against the AfterUpdate and
the Dirty events although the code was still there in the VBA view. By
clicking on the dots at the righthand end of the property on the
property sheet and choosing codebuilder which took me to the
appropriate VBA code then returning to the property sheet [Event
Procedure] now appears and the events do trigger the code. How is it
that the code can be there but doesn't appear to be linked to the
properties? As it was working once it must have become detached
somehow. Is there something I am doing wrong which has caused the to
occur?
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top