Go to a specific record on a form from the same form

  • Thread starter Thread starter shane
  • Start date Start date
S

shane

I wish to be able to go to the record with the associated notification
number. Field name is [notification].

Can I do this with an unbound text box and a button? User would enter the
notification number, click the button, form would go to the record with the
specified notification number (which is indexed, no duplicates). Form
currently allows edits.

Thanks in advanced.
 
You don't need the button. Use the After Update event of the text box to
find the record and make it the current record:

Private Sub txtSearch_AfterUpdate()
With Me.RecordsetClone
.FindFirst "[ClientID] = " & Me.txtSearch
If .NoMatch Then
MsgBox Me.txtSearch & " Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
End Sub
 
Thank you very much.

I would just like to add, for the other new users out there, before pasting
the code into the after update event delete the two default lines:

"Private Sub Text_some number_AfterUpdate()

End Sub"

Not deleting the above lines will generate a compile error.

make sure the data type in [ClientID] or whichever field you use match.

If the data types do not match a compile error will be generated.

Name the text box txtSearch.

After I worked through those issues (my own ignorance) the code worked as
intended.

Klatuu said:
You don't need the button. Use the After Update event of the text box to
find the record and make it the current record:

Private Sub txtSearch_AfterUpdate()
With Me.RecordsetClone
.FindFirst "[ClientID] = " & Me.txtSearch
If .NoMatch Then
MsgBox Me.txtSearch & " Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
End Sub

--
Dave Hargis, Microsoft Access MVP


shane said:
I wish to be able to go to the record with the associated notification
number. Field name is [notification].

Can I do this with an unbound text box and a button? User would enter the
notification number, click the button, form would go to the record with the
specified notification number (which is indexed, no duplicates). Form
currently allows edits.

Thanks in advanced.
 
Glad you worked through it and got it working.
And, what a great learning experience for you.
--
Dave Hargis, Microsoft Access MVP


shane said:
Thank you very much.

I would just like to add, for the other new users out there, before pasting
the code into the after update event delete the two default lines:

"Private Sub Text_some number_AfterUpdate()

End Sub"

Not deleting the above lines will generate a compile error.

make sure the data type in [ClientID] or whichever field you use match.

If the data types do not match a compile error will be generated.

Name the text box txtSearch.

After I worked through those issues (my own ignorance) the code worked as
intended.

Klatuu said:
You don't need the button. Use the After Update event of the text box to
find the record and make it the current record:

Private Sub txtSearch_AfterUpdate()
With Me.RecordsetClone
.FindFirst "[ClientID] = " & Me.txtSearch
If .NoMatch Then
MsgBox Me.txtSearch & " Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
End Sub

--
Dave Hargis, Microsoft Access MVP


shane said:
I wish to be able to go to the record with the associated notification
number. Field name is [notification].

Can I do this with an unbound text box and a button? User would enter the
notification number, click the button, form would go to the record with the
specified notification number (which is indexed, no duplicates). Form
currently allows edits.

Thanks in advanced.
 
Back
Top