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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax to open a record set 1

Status
Not open for further replies.

mgbeye

Programmer
May 30, 2001
47
US
I am using a form that will be pulling from several different tables and a query. I am pretty sure I need to do open recordsets for them. I was wondering if anyone could give me a little help on how exactly to code this. THANKS!
 
there are 2 ways to open a table in Access
DAO and ADO
ADO is newer and preferred casue the code is transferable to WEB pages using VBScript
In Access 2000 you have to specify which by opneing VBA editor an clicking on the "Tools" menu the "References"
and "Check" either one as shown below

DAO refernce = "Microsoft DAO 3.6 ....."
-------------------
Dim db as database, rst as recordset, SQL as string
Set db = CurrentDb
' SQL string.
SQL = "SELECT * FROM yourtabler WHERE yourfield = " & Somevalue
Set rst = db.OpenRecordset(SQL)
rst.movefirst

rst.close
db.close

-------------
reference = "Microsoft ActiveX Data Objects 2.1" (or higher)

ADO
--------
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection ' <<<<Note same as CurrentDb
Dim Rs1 As ADODB.Recordset
Dim SQLCode As String
SQLCode = &quot;SELECT * FROM [STOCK CODE LOOKUP] WHERE STOCK_CODE = '&quot; & Me![Part Number] & &quot;';&quot;
Rs1.Open SQLCode, cnn, adOpenStatic, adLockOptimistic



DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top