|
-
Feb 1st, 2000, 11:18 PM
#1
Thread Starter
Junior Member
How can I search a field in a database when the user clicks on a cmd button?
For example if they wanted to find the name Rhys in a Table called details in a database called MyDatabase..
Assuming that they wrote it into a text area so the button would read the text box then check the database
I know this is easy but I cant get it to work.....
Cheers
Rhys 
-
Feb 1st, 2000, 11:24 PM
#2
This is DAO
Set MySnapshot = MyDB.CreateSnapshot("Select * From details where MyDatabaseField = '" _
& Text1.Text & "'")
Text1.Text contains "Rhys"
------------------
Marty
HASTE CUISINE
Fast French food.
-
Feb 1st, 2000, 11:33 PM
#3
Member
I am assuming you have a database which you have identified with dbName...
Dim db As Database
Dim qdf As QueryDef
Dim rst As Recordset
Dim mySQL As String
Dim result as String
' Define the SQL statement
mySQL = "SELECT * FROM tblName WHERE tblName.Item = '" & TextBox.Text & "'"
' Open a database from which to create the QueryDef object
Set db = OpenDatabase(dbName)
' Create a QueryDef object to retrieve the data
Set qdf = db.CreateQueryDef("")
With qdf
.SQL = mySQL
Set rst = .OpenRecordset()
If Not rst.EOF Then rst.MoveLast
If Not rst.BOF Then rst.MoveFirst
End With
result = rst.Fields(fieldName)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|