Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gotorecord in subform from anther form?

Status
Not open for further replies.
Jan 8, 2002
11
0
0
US
How can I reference a subform from anther form, so I can go to a desired record?

DoCmd.GoToRecord acDataForm, Forms!Main_frm!subform, _ acNewRec

This doesn't work.
To quote Robert De Niro in the movie A Bronx Tale, "there's nothing worse than wasted talent.".
 
You are placing the form reference string in quotes?..

DoCmd.GoToRecord acDataForm, "Forms!Main_frm!SubForm",_
acNewRec

or maybe:

DoCmd.GoToRecord acDataForm, "Forms!Main_frm!SubForm.Form"_
acNewRec
 
Heres somthing i did a couple days ago. This is the code from a button that uses input from a textbox(reflookup) to first find the associated customer and then go to the record on the subform that was initially entered in the textbox. Hopefully this will help out.

Private Sub buttlookup_Click()
On Error GoTo Err_refid
Dim lngCustID As Long
Dim frm As Form
Dim sfrm As Form
Dim rst As DAO.Recordset

'find corresponding cust rec and open

lngCustID = DLookup("custid", "problems", "ProblemID=" & Me.RefLookup)


DoCmd.OpenForm "Customers", , , "CustID =" & lngCustID

'refresh subform and find case

Set sfrm = Forms!Customers![Problem Entry].Form
sfrm.Requery
Set rst = sfrm.RecordsetClone
rst.FindFirst "ProblemID = " & Forms!MainMenu.RefLookup
If Not rst.NoMatch Then sfrm.Bookmark = rst.Bookmark

Err_refid:
' MsgBox ("No Records Found")
Resume Exit_refid

Exit_refid:
Exit Sub

End Sub


Cheers-Sam

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top