Web Development

General discussion


vba programming find record in db

By thinknologist ·
how can i search or find a certain record through a primary key in MS Access database.
I have a database (db), composes of five field and one of them is ID (primary key), firstname, lastname, middlename and picture. I have already designed a IDFORM in form tab. Well the interface looks cool but I wanted it to search for a record in the database.

My logic is like this:
1. Once the user enters their ID number and right after they press enter, the form should automatically search/find that ID number. If the search is not successful a dialog box must be displayed informing user that ID number is not valid. If successfull, a new pop-up form will pop-out in front of user's screen displaying all result of the query.

I have searching for this source code and until i have not found one.
An experts help is highly appreciated.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by john_wills In reply to vba programming find reco ...

Use a combo box with data source something like this:
SELECT Client.ClientID, Client.LastName, Client.FirstName, Format(Client.SSN,"000\-00\-0000") AS SSNFormatted FROM Client ORDER BY Client.ClientID;
Put this in the code for the combo box:
Private Sub Combo272_AfterUpdate() 'find by Client ID
' Find the record that matches the control.
Dim rs As Object
Me.Filter = ""
Set rs = Me.Recordset.Clone
rs.FindFirst "[ClientID] = " & Str(Me![Combo272])
Me.Bookmark = rs.Bookmark
End Sub

Related Discussions

Related Forums