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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.