Selecting a record by number

R

Rayo K

Hello, I have a database with a recordset having a primary key. I want to add
a feature that allows the user to select the recrod ID from either a combo
box or by entering the number in a text box. I know this is possible but I
can't remember how. Please help! Thanks
 
K

Klatuu

Requiring users to remember ID numbers? Not good.

Is this ID an autonumber field and is it the primary key?

Assuming it is, I would suggest a text box. It is faster for a user to
enter a number than to select it from a text box. Here is the usual way to
make a selected record the current record. Use the After Update event of
the text box:

Private Sub txtID_AfterUPdate()

With Me.RecordsetClone
.FindFirst "[IDFieldName] = " & Me.txtID
If .NoMatch Then
MsgBox "Record " & Me.txtID & " Not Found", vbExclamation
Else
Me.Bookmark = .Bookmark
End If
End With
End Sub
 
R

Rayo K

Klatuu said:
Requiring users to remember ID numbers? Not good.

We refer to the records by their ID which is on the report. But if it is
better not to use the primary key for that, let me know.




Thanks for the solution, I will try it out.

Thank you!
 
K

Klatuu

If that is something the users are comfortable with, it is fine. Using
primary keys to find records is a very normal way to do this, but usually,
the user is actuall shown a unique piece of data that is "human" meaningful,
like a name or an SSN.

Not saying it is necessarily wrong, just unusual.
 

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