Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

on lost focus - update 1

Status
Not open for further replies.

hefly

Technical User
Feb 6, 2008
134
US
I have a command button driving an event on a form "Preview Print"

When the entry field looses focus, I would like the field to update, so the results of the entry will display on the print preview.


If try to create an event, I get a VBA script:

Code:
Private Sub Text102_BeforeUpdate(Cancel As Integer)

End Sub

The Macro builder doesn't have an option for the action 'on lost focus update'

How can I get my form to update when the print preview command button is clicked?

Hefly
 
Hi

How can I get my form to update when the print preview command button is clicked?

In the on_Click event of the command button, before the docmd.openreport, put the line

DoCmd.RunCommand acCmdSaveRecord

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thank you so much for responding to my inquiry.

My form has emdeded macros.

I tried placing the DoCmd in the events, I get the message:

"...can't find the object 'DoCmd.'
If 'DoCmd' is a new macro or macro group, make sure you have samved it and that you have typed its name correctlly.

I'm still stuck.

hefly
 
Place the code Ken gave you before running the macro.
Code:
Private Sub ButtonName_Click()
    DoCmd.RunCommand.acCmdSaveRecord
    [i]your macro call goes here[/i]
End Sub

Randy
 
I'm having trouble with this one:

Code:
Private Sub cmdPreviewReport_Click()
    DoCmd.RunCommand.acCmdPrintPreview
End Sub

When I try and run the code, the Macro box pops up, prompting for the macro name. It is not a macro but an event procedure.

 
When I click the command button, I get a compile error:

Argument not optional.

Thanks.

Hefly
 
Hi

Why have you changed the DoCmd ?

If you create a command button (using the wizard) to run your report, it will generate some VBA code, in the OnClick Event of the command button you have created.

Thacode will include a line like so:

DoCmd.OpenReport ... ext etc etc

Add the line of code I gave you:

DoCmd.RunCommand.acCmdSaveRecord

BEFORE the docmd.OpenReport line

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thank you KenRay and Randy.
It works.

Hefly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top