Re: Help on Access DB in VB
This is one of the ways:
strFirst="select FirstName from data1.mdb where LastName =" & text1.text
text2.text = strFirst
What if there are 2 persons with the same last name?
may be, you can use a count and if count>1, pop up a message box
Re: Help on Access DB in VB
sorry, it should be
select FirstName from tableName where LastName = "
You should open the connection obj and the recordset.
Re: Help on Access DB in VB
Ok I got it to work but it won't update the DB when I change the text in a text box or on exit
Re: Help on Access DB in VB
If the user will always have the exact name of the person they are looking for, then you can do as suggested above. But what if they dont know exactly how to spell the person's last name. Or they only enter the first few letters. Then you would have to search for wildcards.
sql = "SELECT * FROM TableName WHERE LastName LIKE '%" & txtLastName.Text & "%'"
The wildcard characters above are for SQL Server, you may have to try * instead of % for Access, I'm not sure about that.
You could have an option button on the search form: One for exact search and one for wildcard search to distinguish when to use the LIKE clause and when not to.
Good luck,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com