Print specific report

Seph

Member
Local time
Today, 03:40
Joined
Jul 12, 2022
Messages
72
Hi everyone,

I'm attempting to use the following VBA code to print a record on a form:

Code:
Me![Paid] = True
Me.Refresh
DoCmd.OpenReport IIf(SalesInvoice, "InvoiceSalesR", "InvoiceJobR"), acViewPreview, , "InvoiceID=" & InvoiceID

The form InvoiceActiveList that the record is on uses a query as its record source.

The query filters and shows only Unpaid records.

So once a record is marked Paid, it "disappears" from the form and moves to InvoicePaidList.

The DoCmd.OpenReport then prints the next Unpaid record in the InvoiceActiveList form.

Is there a method that I can be more specific with the WhereCondition?

Thanks!
 
How do you determine "next" record? If the form and report are sorted in the same order, then you could try modifying the query for the report to only return the first record (TOP 1), then you won't need a Where Condition.
 
A bit confused with what the problem is, do you want to print the record that just disappeared or the next record? What is happening now that is the problem?
Cheers,
 
The logic as you've described it doesn't make any sense. You say you are printing unpaid items, however, you change the paid field to true and then you print that item.
 

Users who are viewing this thread

Back
Top Bottom