lfarnsworth
Registered User.
- Local time
- Today, 13:32
- Joined
- Jul 15, 2008
- Messages
- 25
Hello,
I'm relatively new to VBA programming. I'm trying to do somethingthing relatively simple, that isn't working and I have no idea why.
I've got a form with a subform. Within the subform, I've got two combo boxes: Department and Training. What I want it to do is this: I select a Department and the Training combo box shows me only the training related to it. I've written the query to do that and it works. I've written the VBA code to requery the Training combo box every time I update the Dept combo box. I've written the requery code in the module for the subform. It works, when I run the subform by itself. It gives me a runtime error when I try to run it from the main form. Which, as I write this, I realize is probably what I am doing wrong.
Here is the error
Here is the code:
Do I have the code in the wrong place? Is there something else I am doing wrong? And, of couse, how should I be doing it? Any assistance would be greatly appreciated.
Many thanks in advance,
Leo
I'm relatively new to VBA programming. I'm trying to do somethingthing relatively simple, that isn't working and I have no idea why.
I've got a form with a subform. Within the subform, I've got two combo boxes: Department and Training. What I want it to do is this: I select a Department and the Training combo box shows me only the training related to it. I've written the query to do that and it works. I've written the VBA code to requery the Training combo box every time I update the Dept combo box. I've written the requery code in the module for the subform. It works, when I run the subform by itself. It gives me a runtime error when I try to run it from the main form. Which, as I write this, I realize is probably what I am doing wrong.
Here is the error
Run time error '2450':
Microsoft Office Access can't find the form 'Training Plan Subform' referred to in a macro expression of Visual Basic code.
Here is the code:
Code:
Private Sub Department_AfterUpdate()
Dim ctlCombo As Control
' Return Control object pointing to a combo box.
Set ctlCombo = Forms![Training Plan Subform]![Training]
' Requery source of data for list box.
ctlCombo.Requery
End Sub
Do I have the code in the wrong place? Is there something else I am doing wrong? And, of couse, how should I be doing it? Any assistance would be greatly appreciated.
Many thanks in advance,
Leo