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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connect sql querys to button

Status
Not open for further replies.

pinki

Programmer
Mar 12, 2001
1
DE
if a button was pressed i want execute a SQL Query .
the Problem is i need the return value ,
if an attribute is more then one in the database i will get a message
pe. result=" SELECT * FROM Tabelle WHERE Tabelle.Name='test'"
how can i make it.
 
Ok let me re-frase th equestion a biut so I understand.
1. You want to click a button and pass a SQL statement to your recordset to find more than one instance of something????

------------------- here is a simple example -------
Public Function test()
On Error GoTo Err_test

Dim db As Database, rst As Recordset, SQL As String
Set db = CurrentDb
' SQL string.
SQL = "SELECT * FROM Orders WHERE OrderDate >= #1-1-95#;"
Set rst = db.OpenRecordset(SQL)
rst.MoveLast 'Note if you get an error# 3021 here then you have NO matches
If rst.RecordCount > 1 Then
'you have more than one record
MsgBox "You have " & rst.RecordCount & " records", vbInformation, "You have Matches"
Else
' do something differnt

End If


Exit_test:
Exit Function

Err_test:
Select Case Err.Number
Case 3021
' No current record
'Do something here
Case Else
MsgBox "Error # " & Err.Number & " " & Err.Description, vbInformation, "In Function test"
Resume Exit_test
End Select

End Function
------------------- DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top