Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need VB Code example

Status
Not open for further replies.

ETID

Programmer
Jul 6, 2001
1,867
US
Hi,

Im in need of some VBA code fof MS Access,

I need to findfirst record in a table from a string created from user input, then branch to sub if true or branch to alt sub if false.

Thanks in advance
 
This is for 97 (DAO)

Code:
im dbs As Database
Dim rst As Recordset
Dim strSQL As String
Dim strInput As String
Set dbs = CurrentDb
strInput = Me.txtInput
strSQL = "SELECT * FROM [YourTable] WHERE [YourField] = " & strInput
Set rst = dbs.OpenRecordset(strSQL)
rst.MoveLast
If rst.RecordCount > 0 Then
    'do somethng
Else
    'Do something else
End If
Set rst = Nothing
Set dbs = Nothing
Tyrone Lumley
augerinn@gte.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top