Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Access with Microsoft VB 6

Status
Not open for further replies.

cam7584

Programmer
Jul 25, 2005
4
US
I dont know if this is the place to post this but I need to create a program in VB 6 where the user can type in as many letters as they know of a persons last name, then the app will search an access database and return all the last names that match the search criteria. Then, the user can select a last name from the list and it will provide the user with that persons address and forwarding address information. I know how to do this using VB.Net but I havent used VB 6 in a very long time and I dont even remember how to access the database. I really need some tips and any help I can get. Thanks.
 
You'd probably be better off in the VB forum.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Ah - there you'd only be told to use ADO, open a connection to the db, then open an ADO recordset based on the connection. Something along the lines of the following air code...

[tt]dim rs as adodb.recordset
dim cn as adodb.connection
dim strSql as string
set cn = new adodb.connection
' do the stuff from the link
strSql="select * from mytable where lastname like '%" & txtSearch.text & "%'"
set rs = cn.execute(strSql,,adcmdtext)
if not rs.bof and not rs.eof then
debug.print rs.getstring
end if[/tt]

Should the last name contain single quotes, you'd probably need to utilize the replace function on the string...

To get an updateable recordset, you'd probably need a bit more, but it should be easy to find in help files on ADO.

Roy-Vidar
 
Ah thanks guys, I appreciate the responses. I will try to use that code to get something started.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top