Definition of database variables

I

Ivano Venturi

In the MS Access 2003 User Guide is reported the following example about
AddNew method:

Dim dbsNorthwind As Database
Dim rstEmployees As Recordset

Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set rstEmployees = dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)

As my database name is RegSIP_app.mdb, RegSIP_dat.mdb is the one where are
stored all the data tables and Tab_PreAmb is the name of the table in which I
have to add a new record when user clicks a button on a form stored in
RegSIP_app.mdb, I tried to write something like this:

Dim dbsRegSIP As Database
Dim rstPreAmb As Recordset

Set dbsRegSIP = OpenDatabase("g:\RegSIP\RegSIP_dat.mdb")
Set rstPreAmb = dbsRegSIP.OpenRecordset("Tab_PreAmb", dbOpenDynaset)

I have MS Access 2003 SP3 and it does not work at all ! :-S I mean ... it
gives me a compilation error saying that the user defined type is not defined
!?! Can someone help me to find where is my mistake ?!? Thank you very much
in advance !

Greetings from Modena,
Emilia-Romagna - Italy.
 
D

Douglas J. Steele

While in the VB Editor, select Tools | References from the menu. If
Microsoft DAO 3.6 Object Library isn't one of the selected references,
scroll through the list until you find it and select it. If it is one of the
selected references, do any of the other selected references have MISSING:
in front of them?

Oh, and change your declaration from

Dim rstEmployees As Recordset

to

Dim rstEmployees As DAO.Recordset
 
I

Ivano Venturi

Well done ! Microsoft DAO 3.6 Object Library was not one of the selected
references ... :-S Now I have selected it and it seems to work fine ... thank
you very much ! ;-)

Greetings from Modena,
Emilia-Romagna - Italy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top