Strange error message: Database would be userdefined type!!

G

Gina Meyer

Hi.

I get always a compilation error:
telling me 'myDB As Database' would be user defined type
---------------------------------------------
Public Sub DisplayDetails()

Dim myDB As Database
Dim rs As Recordset

Set myDB = CurrentDb()
Set rs = myDB.OpenRecordset("Arbeit", dbOpenDynaset)

rs.MoveFirst

Do While Not rs.EOF
Debug.Print rs(3) 'material
rs.MoveNext
Loop

rs.MoveLast
rs.Close
myDB.Close

End Sub
----------------------------------------------


I am working inside access 2000 accessing the currently open db and would
like to retrieve some recordsets .. somehow
what am I doing wrong ???

Thanks Gina
 
B

Brian

Gina Meyer said:
Hi.

I get always a compilation error:
telling me 'myDB As Database' would be user defined type
---------------------------------------------
Public Sub DisplayDetails()

Dim myDB As Database
Dim rs As Recordset

Set myDB = CurrentDb()
Set rs = myDB.OpenRecordset("Arbeit", dbOpenDynaset)

rs.MoveFirst

Do While Not rs.EOF
Debug.Print rs(3) 'material
rs.MoveNext
Loop

rs.MoveLast
rs.Close
myDB.Close

End Sub
----------------------------------------------


I am working inside access 2000 accessing the currently open db and would
like to retrieve some recordsets .. somehow
what am I doing wrong ???

Thanks Gina

It looks like you haven't referenced DAO. Open the References window,
scroll down until you find Microsoft DAO Object Library, and put a tick in
the box. Remove the tick against ADO.

It's good practice to fully qualify your object references to make it clear
whether you are using DAO or ADO e.g.

Dim myDB As DAO.Database
 
G

Gina

Thanks Brian.

solved that problem ...

but now I have a different one which is strange as well

____________________________________

Public Sub DisplayDetails(welche As String)
Dim DB As Database
Dim rs As Recordset

Set DB = CurrentDb()
Set rs = DB.OpenRecordset("SELECT * FROM Kunden", dbOpenDynaset,
dbReadOnly)

rs.MoveFirst

Do While Not rs.EOF
Debug.Print rs.Fields(2) 'name
rs.MoveNext
Loop

rs.MoveLast
rs.Close
DB.Close

End Sub

_____________________________________

here --> I get an error telling me types wouldn't match or so ( I work with
a german version)
 
B

Brian

Gina said:
Thanks Brian.

solved that problem ...

but now I have a different one which is strange as well

____________________________________

Public Sub DisplayDetails(welche As String)
Dim DB As Database
Dim rs As Recordset

Set DB = CurrentDb()
Set rs = DB.OpenRecordset("SELECT * FROM Kunden", dbOpenDynaset,
dbReadOnly)

rs.MoveFirst

Do While Not rs.EOF
Debug.Print rs.Fields(2) 'name
rs.MoveNext
Loop

rs.MoveLast
rs.Close
DB.Close

End Sub

_____________________________________

here --> I get an error telling me types wouldn't match or so ( I work with
a german version)

Unfortunately you haven't said which line the error occurs at.

Did you remove the reference to ADO (ActiveX Data Objects)? If not, your
Recordset object declaration is ambiguous, which may be the problem.
Qualifying your object references, as I advised before, would also fix it
i.e.

Dim rs As DAO.Recordset

Opening a dynaset read-only is pointless, and may well not be allowed. If
you don't want to update it, then use dbOpenSnapshot instead of
dbOpenDynaset, and don't bother with dbReadOnly.
 

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