How do I open a recordset and step through it in Access 2000 code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Last version I was familiar with is Access 2.0. We have gone from snapshots to dynasets to recordsets to data sets. Does anyone have sample code to create a database object, create a dataset and step through it in Access 2000?
 
Does anyone have sample code to create a database object, create a
dataset and step through it in Access 2000?

Set wks = DBEngine.CreateWorkspace(This, That, TheOther)
Set db = wks.CreateDatabase("c:\This.mdb", That, TheOther)

strSQL = "CREATE TABLE Test ( " & _
"TestNumber INTEGER NOT NULL CONSTRAINT pk PRIMARY KEY, " & _
"TestThing VARCHAR(12) NOT NULL " & _
")"

db.Execute strSQL, dbFailOnError

strSQL = "INSERT INTO Test (TestNumber, TestThing) " & _
"VALUES (1, ""Eric"");"
db.Execute strSQL, dbFailOnError

strSQL = "INSERT INTO Test (TestNumber, TestThing) " & _
"VALUES (2, ""Samantha"");"
db.Execute strSQL, dbFailOnError

strSQL = "INSERT INTO Test (TestNumber, TestThing) " & _
"VALUES (3, ""Bristol"");"
db.Execute strSQL, dbFailOnError

strSQL = "INSERT INTO Test (TestNumber, TestThing) " & _
"VALUES (4, ""Literacy"");"
db.Execute strSQL, dbFailOnError


Does that help?

Tim F
 
what do wks and db need to be dimensioned as? Access Objects

Here is my old Access 2.0 code that I need to alter to work in Access 200

Function Get_Config(
Dim DB As Databas
Dim SS As Snapsho
Set DB = CurrentDb(
Set SS = DB.CreateSnapshot("Config Query"
Forms![Menu]![Interpolate_From_Zero] = SS("Interpolate_From_Zero"
Forms![Menu]![Interpolation_Interval] = SS("Interpolation_Interval"
SS.Clos
DB.Clos
End Functio
 
Function Get_Config()
Dim DB As Database
Dim RS As Recordset
Set DB = CurrentDb()
Set RS = DB.CreateRecordset("Config Query")
Forms![Menu]![Interpolate_From_Zero] = RS("Interpolate_From_Zero")
Forms![Menu]![Interpolation_Interval] = RS("Interpolation_Interval")
RS.Close
Set RS = Nothing
Set DB = Nothing
End Function
 
What references do you have set up under Tools/ References
on the .CreateRecordset argument I get a compile error: Method or data member not found.
 
Hi Rich,

Doug can confirm for sure when he gets the post, but I
would guess that his code is using DAO 3.6. If you have
this referenced and you are still getting an error, it
may be because you also have ADO referenced. If you
don't use ADO, you can just uncheck it. If you use it
(or plan to) you can explicitly define your variables as
DAO.Database and DAO.Recordset.

-Ted Allen
-----Original Message-----
What references do you have set up under Tools/ References?
on the .CreateRecordset argument I get a compile error:
Method or data member not found.
 
what do wks and db need to be dimensioned as? Access Objects?

Workspace and Database respectively.
Here is my old Access 2.0 code that I need to alter to work in Access
2000
I had assumed that when you posted, "create a database object", you wanted
to create a database object. Rather than a recordset object in a database.
This code is of course quite different and you have had good advice
already. I am still not quite sure what you mean by "step through it"
though.

All the best


Tim F
 
Back
Top