Make a form with
a listbox = List1
an textbox = txtSearch
a commandbutton = cmdGo
assuming there's a database in the 'c:\win' directorie with the name 'test.md'
with a table called 'testing' which contains two fields: 'name' and 'adress'
'on Form1.general
Dim ds as recordset, db as database
Dim criteria$
Const databasenaam="c:\win\test.mdb"
Const tablename="testing"
Sub Form1_load
set db=opendatabase(databasename)
txtSearch.text=""
end sub
Sub cmdGo_Click
Dim SQL$
criteria$= "*" & txtSearch & "*"
SQL$= "SELECT * FROM " & tablename & " WHERE name ='" & _
criteria$ & "'"
set ds = db.openrecordset(SQL$)
do while not ds.eof
List1.additem ds("name") & " " & ds("adress")
ds.movenext
loop
ds.close
end Sub
working with SQL command Like
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment