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
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
---------------------------------------------------------------------
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
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