GoToRecord in subform

First, note the ".Form" in the syntax. It does not always seem to be required, but it might be the problem. Second, it doesn't look like you put in the name of the main form in the first syntax ("MAINFORM" should be replaced by your actual name. Third, is "tblGLCCtransactions_subform" the name of the subform control? Though they may be the same, it doesn't matter what the name of the subform is, what's required is the name of the subform control on the mainform.
 
First, note the ".Form" in the syntax. It does not always seem to be required,
The way Pat Hartman explained it and now I always remember this is this way:

With a subform you have a form within a container (subform control) on the main form; each has its own methods and properties. The subform container has properties and methods and so does the form (subform) within the container (including controls on the form within the container).

If you are trying to access a method, property, or control of the form within the container you need to add .Form. between the subform container name and the property, method, or control name so Access knows you are referring to the form within the subform container control and not the container control itself.

If you get that down, working with subforms suddenly becomes a breeze.
 
Just a thought,

When dealing with subforms I use a trick to create the correct reference.

On the form where I want to place the code I create a text box, and using the expression builder I get this text box to reference the field on the subform I want to manipulate.

This gives me a data source for this text box with the correct syntax to reference the field on the other subform.

I then copy and paste this syntax into my code and delete the text box.

Sounds long winded, but can save a lot of time and frustration in getting the syntax right, especially if you dopn't use it often.

Sue
 
Dont want to hijack the thread but I have been trying the same with an AfterUpdate event on a Combo box to filter a datasheet subform using various combinations of
Me. or no Me and interchanging . and !
Me.Forms!frmMyMainform.frmMySubform.Form.Filter = "[ShipStalk] = " & Me.cboStalkChoice
Me.Forms!frmMyMainform.frmMySubform.Form.FilterOn = True
all I can accomplish is a variety of error messages so I just made a control button to click to open the form with the link criteria. What I would like to accomplish is the drilled down data to be updated in the subform as I progress through some cascading combo boxes.
The cascading works and the correct drill down data appears if the form is opened with a control button, it would be handier to have it update in a subform though.
Just thinking this might be the same sort of direction the original poster might be going...
 
Last edited:
'This code is in the sub-sub-form and is called from the main form:

'Forms!Mainform.SetFocus

'Goto subform then Goto subform's subform
' DoCmd.GoToControl "subform"
' DoCmd.GoToControl "subsubform"

'Find the chosen Record (according to Antenna Number)
'Go to the Record

If Not IsNull(...) Then
intRecNum = Find_Rec_Number(...)
Me.Requery

For i = 1 To intRecNum - 1
DoCmd.GoToRecord , , acNext
Next


End If

'The Above code takes the main from to found record.
'If the DoCmd's are added, the error "Can't go to control" occurs (because it's already at the control?)

I tried the above code today and it worked fine. What was the issue?
 
Are you trying to solve a 5-year-old thread, or did you have a question?
 
:) Ha. I was hoping I would get a good chuckle today. I was researching a similar issue and tried this approach and it worked well. Didn't want others to miss that point. However, if there are issues with the approach, someone should probably correct me.
 

Users who are viewing this thread

Back
Top Bottom