Dim db As DATABASE

G

Guest

Hello,
I'm getting an error message saying that "User Defined Type not Defined"
regarding the second line of code here (Dim db as DATABASE). I know this is a
shot in the dark but could somebody be able to tell me why that's happening?
I'm fairly new to VBA so take pity on me :)


Public Sub CreateCountryRS()
Dim db as DATABASE, rs as RecordSet
Dim a as String
DoCmd.Hourglass True
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblCountry")
Do Until rs.EOF
a = a + rs![Country] + Chr$(10)
rs.MoveNext
Loop
DoCmd.Hourglass False
MsgBox a
rs.Close
End Sub
 
G

Guest

Are you using Access 2000 or Access 97?

You need to check which Reference's VBA is using as 2000 uses ADO and 97
uses DAO (as in your code)

Steve.
 
G

Guest

Hi Steve,
I'm using Access 2000.

FBxiii said:
Are you using Access 2000 or Access 97?

You need to check which Reference's VBA is using as 2000 uses ADO and 97
uses DAO (as in your code)

Steve.

emerb said:
Hello,
I'm getting an error message saying that "User Defined Type not Defined"
regarding the second line of code here (Dim db as DATABASE). I know this is a
shot in the dark but could somebody be able to tell me why that's happening?
I'm fairly new to VBA so take pity on me :)


Public Sub CreateCountryRS()
Dim db as DATABASE, rs as RecordSet
Dim a as String
DoCmd.Hourglass True
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblCountry")
Do Until rs.EOF
a = a + rs![Country] + Chr$(10)
rs.MoveNext
Loop
DoCmd.Hourglass False
MsgBox a
rs.Close
End Sub
 
G

Guest

OK.

Open a module. Select Tools > References from the menu.

Look for Microsoft DAO 3.6 Object Library and select it.

You may need to de-select Microsoft ActiveX Data objects 2.1, but im not sure.

Good Luck!

Steve.

emerb said:
Hi Steve,
I'm using Access 2000.

FBxiii said:
Are you using Access 2000 or Access 97?

You need to check which Reference's VBA is using as 2000 uses ADO and 97
uses DAO (as in your code)

Steve.

emerb said:
Hello,
I'm getting an error message saying that "User Defined Type not Defined"
regarding the second line of code here (Dim db as DATABASE). I know this is a
shot in the dark but could somebody be able to tell me why that's happening?
I'm fairly new to VBA so take pity on me :)


Public Sub CreateCountryRS()
Dim db as DATABASE, rs as RecordSet
Dim a as String
DoCmd.Hourglass True
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblCountry")
Do Until rs.EOF
a = a + rs![Country] + Chr$(10)
rs.MoveNext
Loop
DoCmd.Hourglass False
MsgBox a
rs.Close
End Sub
 
D

Douglas J. Steele

Database is a DAO object. By default, Access 2000 uses ADO.

With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it. If you're not going to be
using ADO, uncheck the reference to Microsoft ActiveX Data Objects 2.1
Library

If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rsCurr as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rsCurr As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


emerb said:
Hi Steve,
I'm using Access 2000.

FBxiii said:
Are you using Access 2000 or Access 97?

You need to check which Reference's VBA is using as 2000 uses ADO and 97
uses DAO (as in your code)

Steve.

emerb said:
Hello,
I'm getting an error message saying that "User Defined Type not Defined"
regarding the second line of code here (Dim db as DATABASE). I know this is a
shot in the dark but could somebody be able to tell me why that's happening?
I'm fairly new to VBA so take pity on me :)


Public Sub CreateCountryRS()
Dim db as DATABASE, rs as RecordSet
Dim a as String
DoCmd.Hourglass True
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblCountry")
Do Until rs.EOF
a = a + rs![Country] + Chr$(10)
rs.MoveNext
Loop
DoCmd.Hourglass False
MsgBox a
rs.Close
End Sub
 
G

Guest

Hey Douglas and Steve,
Thanks a million, that did the trick!!

Emer


Douglas J. Steele said:
Database is a DAO object. By default, Access 2000 uses ADO.

With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it. If you're not going to be
using ADO, uncheck the reference to Microsoft ActiveX Data Objects 2.1
Library

If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rsCurr as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rsCurr As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


emerb said:
Hi Steve,
I'm using Access 2000.

FBxiii said:
Are you using Access 2000 or Access 97?

You need to check which Reference's VBA is using as 2000 uses ADO and 97
uses DAO (as in your code)

Steve.

:

Hello,
I'm getting an error message saying that "User Defined Type not Defined"
regarding the second line of code here (Dim db as DATABASE). I know this is a
shot in the dark but could somebody be able to tell me why that's happening?
I'm fairly new to VBA so take pity on me :)


Public Sub CreateCountryRS()
Dim db as DATABASE, rs as RecordSet
Dim a as String
DoCmd.Hourglass True
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblCountry")
Do Until rs.EOF
a = a + rs![Country] + Chr$(10)
rs.MoveNext
Loop
DoCmd.Hourglass False
MsgBox a
rs.Close
End Sub
 

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

Similar Threads


Top