GoToRecord help

TomJamieson

Registered User.
Local time
Today, 22:14
Joined
Jun 8, 2006
Messages
50
I have a form in datasheet view. The user sees all the records laid out. there is then a text box, where they will type the ID of the record they want to work with, and press one of four buttons that link to different forms.

What i need is for the form to open up on the record that the user typed into the ID text box. So any data already entered onto that record automatically populate the fields on the form. I figured I need to use GoToRecord on the Open Event for each form. I tried using a macro, but it only allows me to go to first, last, next or previous record.

I figured the code would look something like:

Code:
Private Sub Form_EditRecord(Cancel As Integer)
  GoToRecord (frmRecordView!txtID)
End Sub

I'm not even sure if that syntax is right though. Can anyone please help?
 
Nobody has any ideas? I'm really struggling here. Found some syntax for the GoToRecord command, but I can't fit it into my problem.
 
This assumes ID is numeric & ID is the correct field name:

Code:
Private Sub Form_EditRecord(Cancel As Integer)

    Dim stLinkCriteria As String

    stLinkCriteria = "[ID] = " & Me.[I][YourTextBox][/I]

    DoCmd.OpenForm "[I]YourFormName[/I]", , , stLinkCriteria

End Sub

If ID is a String: stLinkCriteria = "[ID] = "'" & Me.[YourTextBox] & "'"

Hope this helps?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom