T
TL
What is the code and where should it be place to update a main form combo box
after entering data into a subform combox?
after entering data into a subform combox?
Try the after update event of the subform combo box.
I have tried the code you detailed but keep coming up with a "Compile
Error:Syntax Error"
Not sure whether the "Parent" section of the "Me.Parent!LOTOGroups" code
referenced the mainform I tried leaving it as parent and also entering the
mainforms name and keep receiving above error.
The subform combo box "LOTOGroups" enters data into a LOTOtable.
The LOTOtable has a one-to-many relationship with a PREVENTTable.
The mainforms combo box "LOTOGroup" has a row source of "SELECT [LOTO
Table].[LOTOGroups] FROM [LOTO Table] ORDER BY [LOTOGroups];"
I'm note sure where I'm going wrong - could it be the query behind the
mainform?
Armen Stein said:I have tried the code you detailed but keep coming up with a "Compile
Error:Syntax Error"
Not sure whether the "Parent" section of the "Me.Parent!LOTOGroups" code
referenced the mainform I tried leaving it as parent and also entering the
mainforms name and keep receiving above error.
The subform combo box "LOTOGroups" enters data into a LOTOtable.
The LOTOtable has a one-to-many relationship with a PREVENTTable.
The mainforms combo box "LOTOGroup" has a row source of "SELECT [LOTO
Table].[LOTOGroups] FROM [LOTO Table] ORDER BY [LOTOGroups];"
I'm note sure where I'm going wrong - could it be the query behind the
mainform?
The rowsource of the combobox shouldn't be an issue, nor should the
query behind they main form. You're having trouble just referencing
the combobox, which result in a compile error. The fact that it is a
syntax error means that you likely haven't written the line of code
correctly. Post your exact code for us to look at.
Also, use the immediate window (Ctrl-G) while your form is open to try
a direct reference.
?Forms!MyMainFormName!LOTOGroups
Does that return a value? If not, maybe the form isn't truly the top
level form, maybe it is another subform?
Armen Stein
Microsoft Access MVP
www.JStreetTech.com
.
See code below:
Private Sub Form_AfterUpdate()
Me.Parent!LOTOGroup
End Sub
This doesn't *DO* anything. It's like sending a postcard saying "Aunt Mary"
and nothing else!
What I am trying to do is update (requery?) a main form combo box after
entering data into a subform combo box?
What I previously sent was the code that was placed into the subform's
update section.
Will the "Me.Parent!LOTOGroup = Me.MyControlOnThisSubform" do this?
Is the "Parent" section of this code supposed to the name of the mainform,
or remain as parent?
LOTOTable (LOTOGroups field) -> LOTOFrmADD (subform) - which has the
LOTOGroups field with the On Update code of the form set to
"Me.Parent!LOTOGroup.Requery"
John W. Vinson said:LOTOTable (LOTOGroups field) -> LOTOFrmADD (subform) - which has the
LOTOGroups field with the On Update code of the form set to
"Me.Parent!LOTOGroup.Requery"
Are you just typing that in the On Update property? If so, change it to [Event
Procedure] and edit it into the VBA code for the event.
I am going into the LOTTOFrmADD form's Properties, Event Tab, After Update
code and typing the code in their?
John W. Vinson said:No.
Click on the ... icon next to the box, and choose Code Builder. This will open
the VBA editor. Write the code there.
LOTOTable (LOTOGroups field) -> LOTOFrmADD (subform) - which has the
LOTOGroups field with the On Update code of the form set to
"Me.Parent!LOTOGroup.Requery"
Am I wrong to assume that 2nd form (LOTOFrmADD) that I open from the 1st
Form (EquipmentFrm) is not truely a subform but rather just another form -
could this be the isse?