Solved Navigate to a text box in a sub form to put a value by a button

Hulk009

New member
Local time
Today, 07:46
Joined
Jun 8, 2024
Messages
17
hello
in my form i have a button when i press it i want it to fill up many text box (RA - MM1 - MM2)
those many text are in a sub form called "TB01"

i've tried this code:

Private Sub Command166_Click()
Me.Parent.Tb01.RA.Value = 27459
Me.Parent.Tb01.MM1.Value = 27894
Me.Parent.Tb01.MM2.Value = 44004
End Sub


it give me Error ... any help with it
 
Is the subform continuous? If it shows multiple records, EXACTLY which record do you think you are updating?

Using Me.Parent..... is valid when the subform wants to reference a control on the parent form. To reference a subform, you qualify the reference by using the name of the subform control - which might be different from the name of the subform object so make sure you are using the correct name. Me.sfrmname.Form!controlname

Having the subform update the parent record or having the parent form update the child form is ALWAYS cause for questioning your logic. I sometimes have unbound controls on the parent form which show totals of the subform data and to make sure they always get updated when a subform record gets updated, I generally have code in the AfterUpdate event of the subform to push the data to the unbound controls on the main form.
 
I think the O/P is just confused?
If the code was in the mainform then Parent would not be used, but .Form should be?
If in the subform, again no need for Parent or subform control name.

From the very little posted I think the button is on the mainform and the textboxes in the subform, so the link should show them the syntax.
 

Users who are viewing this thread

Back
Top Bottom