GoToRecord question?

caferacer

Registered User.
Local time
Today, 20:21
Joined
Oct 11, 2012
Messages
96
Hi All,

I have a combo box "VendorID" on a subform, where after update I am trying to requery the parent form [frm Equipment Primary] and return back to the record which has just been updated. I have found the code below on the net,

Private Sub YourControl_AfterUpdate()
Dim recNum As Long

recNum = Me.CurrentRecord
Me.Requery
DoCmd.GoToRecord acDataForm, "YourForm", acGoTo, recNum

End Sub


Which I have modified to

Private Sub VendorID_AfterUpdate()

Dim recNum As Long

recNum = Forms![frm Equipment Primary].CurrentRecord
Forms![frm Equipment Primary].Requery
DoCmd.GoToRecord acDataForm, Forms![frm Equipment Primary], acGoTo, recNum

End Sub

but it throws the error "2498 wrong data type for one of the arguments". Any ideas?

I tried the immediate window to see the status of recNum, but it returned "variable not yet created in this context"?

Thanks and regards

Mark.
 
Update. Spotted a mistake - fogot the "" around the form name. Now getting 2489, the object 'forms![frm Equipment Primary]' isn't open - but it is?

Private Sub VendorID_AfterUpdate()

Dim recNum As Long
recNum = Forms![frm Equipment Primary].CurrentRecord
Forms![frm Equipment Primary].Requery
DoCmd.GoToRecord acDataForm, "Forms![frm Equipment Primary]", acGoTo, recNum
End Sub

Any ideas, thanks.
 

Users who are viewing this thread

Back
Top Bottom