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

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.
 
K

Klatuu

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
 
S

shane

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.
 
K

Klatuu

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top