Formatting report with Events

P

PaulB

Hello all,

I have a report which is in fact an invoice. Depending on the status
of a client, I want to hide or show some information (both labels and
text boxes) on the footer of the report.
Therefor, I've written a VBA script in this report which is activated
by the Open-event.
It is something like:
If condition = true then
me!label1.visible = true
me!textbox1.visible = true
else
me!label1.visible = false
me!textbox1.visible = false
endif
In the report itself, all these labels and text boxes are not visible
by default.

If I preview this report on my screen, this works fine. But if I
actually print the report directly from another script
(docmd.openreport "RepInvoice") all the labels and text boxes are not
printed, regardless if the condition is met or not.

Who has any suggestions to solve this? Thank you very much for your
ideas.

Paul
 
M

Marshall Barton

PaulB said:
Hello all,

I have a report which is in fact an invoice. Depending on the status
of a client, I want to hide or show some information (both labels and
text boxes) on the footer of the report.
Therefor, I've written a VBA script in this report which is activated
by the Open-event.
It is something like:
If condition = true then
me!label1.visible = true
me!textbox1.visible = true
else
me!label1.visible = false
me!textbox1.visible = false
endif
In the report itself, all these labels and text boxes are not visible
by default.

If I preview this report on my screen, this works fine. But if I
actually print the report directly from another script
(docmd.openreport "RepInvoice") all the labels and text boxes are not
printed, regardless if the condition is met or not.


I suspect the problem in in: If condition = True Then

What is the condition? How can it be affected by the
different ways of opening the report?
 
P

PaulB

Marshall Barton said:
I suspect the problem in in: If condition = True Then

What is the condition? How can it be affected by the
different ways of opening the report?

The actual condition is:
If DLookup("Status", "TblCustomers", "Customernumber =
Customernumber2") = "Distributer" then

In this line Customernumber refers to a field in table TblCustomers,
and Customernumber2 is the name of a text box (control source =
Customernumber) in my report.
As stated before, this script works exactly as needed when the report
is shown in print preview. Only when the report is actually printed,
all the labels and text boxes are not visible.
Thank you and kind regards,

Paul
 
M

Marshall Barton

PaulB said:
The actual condition is:
If DLookup("Status", "TblCustomers", "Customernumber =
Customernumber2") = "Distributer" then

In this line Customernumber refers to a field in table TblCustomers,
and Customernumber2 is the name of a text box (control source =
Customernumber) in my report.
As stated before, this script works exactly as needed when the report
is shown in print preview. Only when the report is actually printed,
all the labels and text boxes are not visible.


Use this instead:

If DLookup("Status", "TblCustomers", "Customernumber = " _
& Customernumber2) = "Distributer" Then
 

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