Click to See Complete Forum and Search --> : More DB Questions
Dayo312
Jan 9th, 2000, 04:44 AM
I have a Few more DB Questions if someone would kind enough to answer them :)
If I put "Cheese" in a text box, and I want it to go find the word cheese In a field and bring up the whole record; how could I do that??
How Can I state which record to move to??
LG
Jan 9th, 2000, 05:05 AM
Hi,Dayo321.
There is a code, but you have to keep in mind, that text in Text box should be the same as in database field :
Private Sub Command2_Click()
Dim sql As String
sql = "select * from categories where description = " & Chr(34) & Text1.Text & Chr(34)
Data1.RecordSource = sql
Data1.Refresh
End Sub
If you're not sure of the text, you should use another sql:
sql = "select * from categories where description like " & Chr(34) & Text1.Text & Chr(42) & Chr(34)
Chr(34) is ""
Chr(42) is *
Larisa
LG
Jan 9th, 2000, 05:07 AM
Sorry, I misspelled you name.
Larisa
Dayo312
Jan 9th, 2000, 07:57 AM
Thanks, Your real knowledgable.
My name is Evan :)
Dayo312
Jan 9th, 2000, 08:35 AM
Grr..
Another error.
Umm.. Ok I Wrote ..
SQL = "select * from categories where description like " & Chr(34) & Text1.Text & Chr(42) & Chr(34)
Data1.RecordSource = SQL
Data1.Refresh
And It said
"The Microsoft jet engine cannot find input table or query. Make sure it exists and the name spelled correct."
The Dbsourse is called "General"
Whats wrong??
LG
Jan 10th, 2000, 06:25 AM
Hi, Evan.
To work with database you have to know sql.Here is link to sql tutorial: http://w3.one.net/~jhoffman/sqltut.htm
I gave you example that will work with Northwind database. But if you are working with another db, you have to put in select statement your table name and field name.
In my sample * means that I select all fields from table Categories.
So table name is Categories.
And field name is Description
So you have to check your database, if table that you are using in select statement exists and you spelled it correctly. The same goes for field name.
I hope you understand my explanation. English is not my native language.
Larisa
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.