Updating combobox in sub subform

Zul77

New member
Local time
Tomorrow, 07:03
Joined
Feb 16, 2010
Messages
7
Hi;

I have a form which is a 3 levels of form... mainform, subform and sub subform.

cboCategory will be populated based on two combobox namely cboGender and cboGrade. I did this succesfully without any problem. All of this combobox are in the subform.

Now I have another combobox, cboEvent which is in sub subform. I want this cboEvent to be populated based on changes in the cboCategory (in the subform). However it works only at the first data. When I'm going to add or move to the next data, the category have no change no matter what is happening to cboCategory.

I hope some will have time to look at my Db and please let me know what is wrong with it. Thank you so much.
 

Attachments

Thanks for the link. I have study the link but I'm not really understand how to use it.

Here is VB code that I put in the sub subform.

Private Sub cboCategory_AfterUpdate()
cboEvent = Null
If Me.NewRecord Then Me.frmStudentEvent SubForm.Requery
cboEvent.Requery
cboEvent = Me.cboEvent.ItemData(0)
End Sub
Private Sub Form_Current()
cboEvent.Requery
End Sub

FYI;

subform name: frmStudent subform
subform controller: tblStudent subform

sub subform name: frmStudentEvent subform
subform controller: tblStudentEvent subform

Still I got the frmEvent inherited the category value as same as the first record when the form starts.
 
Thanks for the link. I have study the link but I'm not really understand how to use it.

Here is VB code that I put in the sub subform.

Private Sub cboCategory_AfterUpdate()
cboEvent = Null
If Me.NewRecord Then Me.frmStudentEvent SubForm.Requery
cboEvent.Requery
cboEvent = Me.cboEvent.ItemData(0)
End Sub
Private Sub Form_Current()
cboEvent.Requery
End Sub

FYI;

subform name: frmStudent subform
subform controller: tblStudent subform

sub subform name: frmStudentEvent subform
subform controller: tblStudentEvent subform

Still I got the frmEvent inherited the category value as same as the first record when the form starts.
 
Are you using the "Me" feature for you combo boxes on the subforms? I don't think you do that.

It has to be something like

Forms!SubformName.controlname.requery
 
Subform syntax can be very confusing to people.

First of all, the thing to remember is that there is a control on the main form (or another subform) which basically "houses" the subform on the form. So, when you are referring to a subform you want to refer to that CONTROL and not the subform itself (unless it has the exact same name as the subform control).

So, for example, if I have:

Main Form: frmMain
1st Level Subform Control: Child1
1st Level Subform that is in 1st Level Subform Control: sfrmTest
2nd Level Subform Control (on 1st Level subform): Child2
2nd Level Subform that is in 2nd Level Subform Control: sfrmAnother

So, if I want to refer to a control (say a combo box named cboMyBox) on the sfrmAnother from my main form I would use this code:

Me.Child1.Form.Child2.Form.cboMyBox.Requery

Or I could use

Me.Controls("Child1").Form.Controls("Child2").Form.Controls("cboMyBox").Requery

So, if I am referring to the second level subform from the first level subform I would use:

Me.Child2.Form.cboMyBox.Requery


Does that help?
 
Are you using the "Me" feature for you combo boxes on the subforms? I don't think you do that.

It has to be something like

Forms!SubformName.controlname.requery

Yes you're right. I use the code in the Vb design view and not in the record source of the combobox.

And guys, it works now... Thanks to SOS for your guide and ajetrumpet for the link :)
 

Users who are viewing this thread

Back
Top Bottom