Type Declaration error (1 Viewer)

E

edwinsc

Guest
I have made the following code to make a same report with differents parameters that I get from a database:
---------------------------------------------------------------------
Sub Make_reports()

Dim DbsAtual As Database
Dim RstRel As Recordset
Dim Linha As String
Dim Cond As String
Dim NomeRel As String
Dim Contador As Integer

Set DbsAtual = CurrentDb
Set RstRel = DbsAtual.OpenRecordset("Tb_celular", dbOpenSnapshot)

With RstRel

RstRel.MoveFirst


Do While Not RstRel.EOF
On Error Resume Next

Linha = Trim(RstRel![NUMERO_CEL])

NomeRel = NUMERO_CEL

Cond = "NRO_CELULAR =" & """" & Linha & """"

DoCmd.CopyObject , NomeRel, acReport, "Rt_ContaDeCelular"

DoCmd.OpenReport NomeRel, acViewNormal, , Cond

RstRel.MoveNext
On Error GoTo 0
Loop


End With

Set RstRel = Nothing

RstRel.Close

DbsAtual.Close

End Sub
-----------------------------------------------------------
But when I try to compile I get a message error that the user type Database is undeclared, so the error must be in the line:

Dim DbsAtual As Database :confused:

I think the type Database is not available, but Access' help uses similar declaration. I runned this code on Access 2003 e no XP and got the same message error.
Any suggestion?
Thanks
Edwin
 

bat1799

Registered User.
Local time
Today, 09:07
Joined
Nov 18, 2005
Messages
27
In any module go Tools>References...
Scroll down and select "Microsoft DAO 3.6 Object Library"
Ref number may vary!

Change the to Dims to
Dim DbsAtual As Dao.Database
Dim RstRel As Dao.Recordset


HTH

Peter
 

Users who are viewing this thread

Top Bottom