Alter Code for Batch Printing

B

Bob

This is my code to print a statement by selecting date range and OwnerName,
at the bottom of the code there is something about batch printing
statements but it is greened out. Can I use this for batch printing all
owners staements at todays date? Thanks for your Help......Bob

Private Sub cmdStatement_Click()

Select Case Me.OpenArgs

Case "OwnerStatement"

If IsNull(cbOwnerName.value) = True Or cbOwnerName.value =
vbNullString Then
MsgBox "Please Select the Owner.", vbApplicationModal +
vbInformation + vbOKOnly
Exit Sub
End If

Me.Visible = False
DoCmd.OpenReport "rptOwnerPaymentMethod", acViewPreview
'DoCmd.Close acForm, Me.Name
Case "MonthlyPaid"

Me.Visible = False
DoCmd.OpenReport "rptGenericReport", acViewPreview, , , ,
"MonthlyPaid"
'Report_rptGenericReport.tbTotal.value =
SUM(Report_rptGenericReport.tbAmount)
'DoCmd.Close acForm, Me.Name
'Report_rptGenericReport.tbTotal =
DSum(Report_rptGenericReport.tbAmount, "rptGenericReport")
'Report_rptGenericReport.tbTotal.ControlSource =
"Sum(Report_rptGenericReport.tbAmount)"
DoCmd.Close acForm, Me.Name
Case "OwnerDue"

Me.Visible = False
DoCmd.OpenReport "rptGenericReport", acViewPreview, , , ,
"OwnerDue"
DoCmd.Close acForm, Me.Name
Case "OwnerPaymentMethod"

If IsNull(cbOwnerName.value) = True Or cbOwnerName.value =
vbNullString Then
MsgBox "Please Select the Owner.", vbApplicationModal +
vbInformation + vbOKOnly
Exit Sub
End If

Me.Visible = False
DoCmd.OpenReport "rptGenericReport", acViewPreview, , , ,
"OwnerPaymentMethod"
DoCmd.Close acForm, Me.Name

Case "PaymentMethod"

Dim nDateDiff As Integer, nSign As Integer
nDateDiff = DateDiff("d", CDate(tbDateFrom.value),
CDate(tbDateTo.value))
nSign = Sgn(nDateDiff)

If nSign = -1 Or nSign = 0 Then
MsgBox "Please Select Date In Proper Range.",
vbApplicationModal + vbExclamation + vbOKOnly
cmdCalenderTo.SetFocus
Exit Sub
End If

Me.Visible = False
DoCmd.OpenReport "rptGenericReport", acViewPreview, , , ,
"PaymentMethod"
DoCmd.Close acForm, Me.Name
Case "PrintInvoiceBatch"
If IsNull(tbDateFrom.value) Or tbDateFrom.value = "" Or
IsNull(tbDateTo.value) Or tbDateTo.value = "" Then
MsgBox "Please Enter the Begining Date and End Date.",
vbApplicationModal + vbInformation + vbOKOnly
Exit Sub
End If
Me.Visible = False
DoCmd.OpenReport "rptInvoiceBatch", acViewPreview, , , ,
"PrintInvoiceBatch"
'DoCmd.Close acForm, Me.Name
Case "PrintStatementBatch"
' If IsNull(tbDateFrom.value) Or tbDateFrom.value = "" Or
IsNull(tbDateTo.value) Or tbDateTo.value = "" Then
' MsgBox "Please Enter the Begining Date and End Date.",
vbApplicationModal + vbInformation + vbOKOnly
' Exit Sub
' End If
Me.Visible = False
DoCmd.OpenReport "rptOwnerPaymentMethodBatch", acViewPreview, , , ,
"PrintStatementBatch"
'DoCmd.Close acForm, Me.Name
End Select
'DoCmd.OpenReport "rptInvoiceBatch", acViewPreview, , , ,
"PrintInvoiceBatch"
End Sub
 
T

Tom Wickerath

Hi Bob,

The easiest way to tell is to try it out. The code that you called "greened
out" is more correctly termed commented out. For whatever reason, the person
who wrote this code left it commented out. Perhaps they could not get it to
work as expected, but they weren't ready to delete it.

Make a back-up copy of your database first. Then try uncommenting the lines
of code, by removing the leading apostrophe symbol. Click on Debug > Compile
ProjectName when finished (where ProjectName is the name of your VBA
project). Does your code compile properly? If so, this option should become
greyed out.

This line of code:
DoCmd.OpenReport "rptInvoiceBatch", acViewPreview, , , , "PrintInvoiceBatch"

indicates to me that the report named rptInvoiceBatch is being passed an
OpenArg (PrintInvoiceBatch). You might open the code module associated with
this report to see if there is any code that checks for an OpenArg and makes
use of it. This would likely be in a report open event procedure.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
T

Tom Wickerath

Hi Bob,

The easiest way to tell is to try it out. The code that you called "greened
out" is more correctly termed commented out. For whatever reason, the person
who wrote this code left it commented out. Perhaps they could not get it to
work as expected, but they weren't ready to delete it.

Make a back-up copy of your database first. Then try uncommenting the lines
of code, by removing the leading apostrophe symbol. Click on Debug > Compile
ProjectName when finished (where ProjectName is the name of your VBA
project). Does your code compile properly? If so, this option should become
greyed out.

This line of code:
DoCmd.OpenReport "rptInvoiceBatch", acViewPreview, , , , "PrintInvoiceBatch"

indicates to me that the report named rptInvoiceBatch is being passed an
OpenArg (PrintInvoiceBatch). You might open the code module associated with
this report to see if there is any code that checks for an OpenArg and makes
use of it. This would likely be in a report open event procedure.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
B

Bob

Hi Tom , the Invoice batch does work prints invoices by batch. I am trying
to get Statements to do the same...Thanks bob
 
T

Tom Wickerath

Hi Bob,

Yes, I was talking about the commented out code for Case
"PrintStatementBatch". It looks like the commented out lines of code were
written to verify that a user entered dates in the tbDateFrom and tbDateTo
textboxes.

Add a break point to the beginning of your code module. To do this, click in
the left-hand grey margin. You should see a maroon colored dot, along with
the line of code being highlighted maroon. For example, do this on the first
line of code that reads Select Case Me.OpenArgs. Add a line of code (just
for testing) right after the first line of code:
MsgBox Me.OpenArgs

What OpenArg value do you see? Is is the text string: PrintStatementBatch ?

Continue executing the code one-line-at-a-time, by pressing the F8 key. Does
the appropriate branch of code get executed? Keep pressing the F8 key. Does
the code for the rptOwnerPaymentMethodBatch report display? Is it making use
of this openarg value that was passed to it?

Note: To step through code, you must have the Special Keys option checked,
under Tools > Startup.



Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
B

Bob

Got it to Work by using the Commented out , but now I am getting a error
"Enter parameter Value, tbOwnerName" but after I OK it works fine....Thanks
Bob
Anything I can do with the error?
 
T

Tom Wickerath

Okay, sounds like you are making progress!

Try to determine if the source of this parameter error is in the report, or
in the recordsource (likely a query or SQL statement) for the report in
question. Open the report in design view. Click on View > Properties to
display the Properties dialog (if it is not already displayed). Click on the
small black square in the upper left corner, if necessary, to display the
properties for the report. You should see the word "Report" in the blue title
bar. Click on the Data tab. The first entry should be recordsource. Click
into the recordsource. You should see a build button become visible (ie. a
button with three dots, off to the right-hand side). Click on the build
button. If you get a prompt that reads "You invoked the query builder on a
table", then click No to dismiss. Otherwise, run the query by clicking on the
Exclaimation mark. Do you get prompted for this parameter at this time? If
the answer is Yes, then you need to fix the query. If the answer is No, then
close the query builder without saving any changes. I'm assuming that
tbOwnerName refers to a textbox, but it might be referring to a field. Click
on View > Field List. Do you see this as a listed field name?

Still in design view for your report, verify that you do not have a Filter
property set to tbOwnerName. This property is just below the Record Source
property. Then click on View > Sorting and Grouping. Verify that nothing
named tbOwnerName is displayed in the list (if it is, then it must be
available to the report in the Field List).

Use a process of elimination to determine if the error is in a query that
serves as the report's recordsource, or if the error is in the report itself.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
B

Bob

Fixed It Thanks

Bob said:
Got it to Work by using the Commented out , but now I am getting a error
"Enter parameter Value, tbOwnerName" but after I OK it works
fine....Thanks Bob
Anything I can do with the error?
 

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