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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA code in Open Event causes print to silently fail 1

Status
Not open for further replies.

postermmxvicom

Programmer
Jun 25, 2007
114
US
I have the following code in the Open event of my report:

Code:
    Me.LotNumber_Label.Caption = [Forms]![LotNumberTrace]![LotKey].Text

I had this code in my Load event, but it would only run when the report is previewed and not when it was printed via a command from a form.

So...I moved the code to the Open event, which is called when a report is printed, hoping it would run. Everything appears to be fine, it says it's printing. However, nothing is actually printed.

What event should I be putting this code in? Or is there something else in play here that I need to address?

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
I would place the code in the On Format event of the section containing the control. Also, you can't use the "Text" property unless the control has the focus. Use the "Value" property or no property.
Code:
    Me.LotNumber_Label.Caption = [Forms]![LotNumberTrace]![LotKey]

Make sure you are not closing form LotNumberTrace at any point when the report is open or is closing.

Duane
Hook'D on Access
MS Access MVP
 
Thanks dhookom,

That was the event I needed! I have another question for you though.

Also, you can't use the "Text" property unless the control has the focus. Use the "Value" property or no property.

Value gives me the Key which is stored in the combobox, not the human-important data that I need to show on the report. So, I called setfocus and then used text. Is there another way to do this? Can I get the value from the column displayed in the combobox instead of the value stored another way?

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
You can generally reference the displayed column using the Column(x) property where x is the column number based on 0 being the first column.
[Forms]![LotNumberTrace]![LotKey].Column(x)

Duane
Hook'D on Access
MS Access MVP
 
Thanks dhookom!

I wish I could give you two stars :/ I thought I'd seen something like that somewhere before, but I was unable to turn it up.

Aaron

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top