print funtion error

2 views
Skip to first unread message

after.e...@gmail.com

unread,
Apr 17, 2006, 1:19:32 PM4/17/06
to Access / VBA development
I dont have much experience with visual basic or Microsoft Access, so
heres my problem.

I am converting old databases from access 97 ot 2003, and I have
successfully done it. Now, I'm going through each form to see if it
works the same way it used to. Everything was good until I came across
a print function.
I get this error:


Compile Error: User-Defined type not defined.

The printer is an Epson FX 880 Dot Matrix, and thats not the problem to

my knowledge. If anyone has any clue on how I can get this to print,
please fill me in.


Here are screenshots of what I am doing:
This is where i press the print button.
http://i4.photobucket.com/albums/y102/xmav27x/error1.jpg


This is what comes up.
http://i4.photobucket.com/albums/y102/xmav27x/error2.jpg


Thanks.

Heres the code that pops up with the error.

Option Compare Database 'Use database order for string comparisons

Function PrintExpenditure(Sarg As String)
Dim db As Database, ds As Dynaset, nb As Database, ns As Dynaset
If Sarg = "S" Then
Set db = CurrentDb()
Set ds = db.CreateDynaset("vouchquery")
msg = "Please enter voucher number to print"
title = "Voucher Request"
answer = InputBox$(msg, title)
If Len(answer) = 0 Then
Exit Function
End If
msg = "Please enter voucher number " + answer
title = "Insert Voucher"
button = MsgBox(msg, 1 + 64, title)
If button = 2 Then
ds.Close
Exit Function
End If
criteria = "[Voucher Number] = '" + answer + "'"
ds.FindFirst criteria
If ds.NoMatch Then
ds.Close
Exit Function
Else
DoCmd.OpenReport "vouchexprep", A_PRINT, , criteria
DoCmd.Close A_REPORT, "vouchexprep"
End If
ds.Close
Else
Set db = CurrentDb()
Set ds = db.CreateDynaset("vouchquery")
Set nb = CurrentDb()
Set ns = nb.CreateDynaset("bugapprop")
criteria = "[ExpPrinted] = No"
ds.FindFirst criteria
Do Until ds.NoMatch
vouchid = ds![Voucher Number]
repstring = "[Voucher Number] = '" + vouchid + "'"
ncriteria = repstring
ns.FindFirst ncriteria
If Not ns.NoMatch Then
msg = "Please enter voucher number " + vouchid
title = "Insert Voucher"
button = MsgBox(msg, 1 + 64, title)
If button = 2 Then
ds.Close
ns.Close
Exit Function
End If
DoCmd.OpenReport "vouchexprep", A_PRINT, , repstring
DoCmd.Close A_REPORT, "vouchexprep"
ds.Edit
ds![ExpPrinted] = -1
ds.Update
End If
ds.FindNext criteria
Loop
ds.Close
End If

End Function

Function PrintVoucher(Sarg As String)
Dim db As Databased, ds As Dynaset
If Sarg = "S" Then
Set db = CurrentDb()
Set ds = db.CreateDynaset("vouchquery")
msg = "Please enter voucher number to print"
title = "Voucher Request"
answer = InputBox$(msg, title)
If Len(answer) = 0 Then
Exit Function
End If
msg = "Please enter voucher number " + answer
title = "Insert Voucher"
button = MsgBox(msg, 1 + 64, title)
If button = 2 Then
ds.Close
Exit Function
End If
criteria = "[Voucher Number] = '" + answer + "'"
ds.FindFirst criteria
If ds.NoMatch Then
ds.Close
Exit Function
Else
DoCmd.OpenReport "vouchrep", A_PRINT, , criteria
DoCmd.Close A_REPORT, "vouchrep"
End If
ds.Close
Else
Set db = CurrentDb()
Set ds = db.CreateDynaset("vouchquery")
criteria = "[Printed] = No"
ds.FindFirst criteria
Do Until ds.NoMatch
vouchid = ds![Voucher Number]
repstring = "[Voucher Number] = '" + vouchid + "'"
msg = "Please enter voucher number " + vouchid
title = "Insert Voucher"
button = MsgBox(msg, 1 + 64, title)
If button = 2 Then
ds.Close
Exit Function
End If
DoCmd.OpenReport "vouchrep", A_PRINT, , repstring
DoCmd.Close A_REPORT, "vouchrep"
ds.Edit
ds![Printed] = -1
ds.Update
ds.FindNext criteria
Loop
ds.Close
End If

End Function

Ozzone

unread,
Apr 18, 2006, 1:43:55 AM4/18/06
to Access / VBA development
You made a typo. It isn't Database(d), it's Database.
Reply all
Reply to author
Forward
0 new messages