Update record before print

  • Thread starter Mike Langensiepen
  • Start date
M

Mike Langensiepen

I have a data entry form to take payments from a client. On the form is a
'print receipt' button which calls a single page report.

If I put in a payment and tab out of the payment field or press enter on the
payment field then click the print button, the most recent payment doesn't
show on the report. If I go forward a record and then back then it prints
out correctly.

I assume I have to update the record before printing but don't know the
command I need to use. Here is the current Button command sequence:

Private Sub Command357_Click()
DoCmd.OpenReport "PAYRECEIPT", acViewPreview, , "[ContactLastName]=""" &
Me.ContactLastName & """", acWindowNormal
DoCmd.PrintOut acSelection
DoCmd.Close
End Sub

Thanks

Mike
 
T

tina

add either

Me.Dirty = False

or

DoCmd.RunCommand acCmdSaveRecord

to your procedure, *before* the OpenReport action. and btw, you don't need
to open the report in Preview in order to print. just do an OpenReport
action, with a WHERE clause argument to filter the report's RecordSource to
return only the current record on the form - the default "open" action is
Print, not Preview. suggest you read up on the OpenReport Action topic in
VBA Help, so you'll understand how the arguments work.

hth
 
M

Mike Langensiepen

Hi Tina,

That worked wonderfully thanks. The record changes save, preview is now off
and the form prints perfectly.


tina said:
add either

Me.Dirty = False

or

DoCmd.RunCommand acCmdSaveRecord

to your procedure, *before* the OpenReport action. and btw, you don't need
to open the report in Preview in order to print. just do an OpenReport
action, with a WHERE clause argument to filter the report's RecordSource
to
return only the current record on the form - the default "open" action is
Print, not Preview. suggest you read up on the OpenReport Action topic in
VBA Help, so you'll understand how the arguments work.

hth


Mike Langensiepen said:
I have a data entry form to take payments from a client. On the form is a
'print receipt' button which calls a single page report.

If I put in a payment and tab out of the payment field or press enter on the
payment field then click the print button, the most recent payment
doesn't
show on the report. If I go forward a record and then back then it prints
out correctly.

I assume I have to update the record before printing but don't know the
command I need to use. Here is the current Button command sequence:

Private Sub Command357_Click()
DoCmd.OpenReport "PAYRECEIPT", acViewPreview, , "[ContactLastName]=""" &
Me.ContactLastName & """", acWindowNormal
DoCmd.PrintOut acSelection
DoCmd.Close
End Sub

Thanks

Mike
 
T

tina

you're welcome :)


Mike Langensiepen said:
Hi Tina,

That worked wonderfully thanks. The record changes save, preview is now off
and the form prints perfectly.


tina said:
add either

Me.Dirty = False

or

DoCmd.RunCommand acCmdSaveRecord

to your procedure, *before* the OpenReport action. and btw, you don't need
to open the report in Preview in order to print. just do an OpenReport
action, with a WHERE clause argument to filter the report's RecordSource
to
return only the current record on the form - the default "open" action is
Print, not Preview. suggest you read up on the OpenReport Action topic in
VBA Help, so you'll understand how the arguments work.

hth


Mike Langensiepen said:
I have a data entry form to take payments from a client. On the form is a
'print receipt' button which calls a single page report.

If I put in a payment and tab out of the payment field or press enter
on
the
payment field then click the print button, the most recent payment
doesn't
show on the report. If I go forward a record and then back then it prints
out correctly.

I assume I have to update the record before printing but don't know the
command I need to use. Here is the current Button command sequence:

Private Sub Command357_Click()
DoCmd.OpenReport "PAYRECEIPT", acViewPreview, , "[ContactLastName]=""" &
Me.ContactLastName & """", acWindowNormal
DoCmd.PrintOut acSelection
DoCmd.Close
End Sub

Thanks

Mike
 

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

Top