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 = "SELECT * FROM [STOCK CODE LOOKUP] WHERE STOCK_CODE = '" & Me![Part Number] & "';"
Rs1.Open SQLCode, cnn, adOpenStatic, adLockOptimistic
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.