View Full Version : subform problem


arage
08-01-2001, 07:18 AM
I’ve never used subforms before & am trying now.
My subform is based on several table fields and the main form’s record source is the entire table. The form has a 2 unbound controls, Ref# and Invoice#. What I’m attempting to do is fill in either of the latter controls and then use a Goto record command that will take me to the appropriate record in the subform. I’ve never used the latter goto command before either & would appreciate any advice on how to approach this problem.

I’m using the above to update accounting details, I search by Ref# or Invoice#, then goto the appropriate subform record (which lists accounting details) and then fill in the accounting fields.

Here’s a sample of the code I put in the afterUpdate event of my Ref# control. The error I get is that the ‘tblNewMainCopy subform’ object is not open. Run time error 2489.

Private Sub txtReference__AfterUpdate()
DoCmd.GoToRecord acDataForm, "tblNewMainCopy subform", acGoTo
End Sub

Rich
08-01-2001, 07:26 AM
Try
DoCmd. GoToControl, "tblNewMainCopy subform",
DoCmd.DoCmd.GoToRecord etc

arage
08-01-2001, 07:31 AM
i get run time error 438 'obj doesnt support this property or method' when i use the below code as per your suggestion Rich.

Private Sub txtReference__AfterUpdate()
DoCmd.GoToControl "tblNewMainCopy subform"
DoCmd.DoCmd.GoToRecord acDataForm, "tblNewMainCopy subform", acGoTo
End Sub

[SK]Gondrik
04-08-2007, 08:43 AM
Hi I've the same problem like 'arage' and I used Your Idea 'Rich' and it's working. It needs just ignoring twice DoCmd in Your Thread, so finally it should look's like this:

Private Sub txtReference__AfterUpdate()
DoCmd.GoToControl "tblNewMainCopy subform"
DoCmd.GoToRecord , , acGoTo
End Sub

Thanks 4 Idea