Display label and text box field based on company number

C

CAM

Hello,

I am using MS Access 2003. How do I display label and text box field only
when a certain company is to be printed. I have a field call
"companyNumber" and I want to use that field to display or don't display one
particular label and text box field. For example

I have a companyNumber 111

I want to display "labelCompany" and "txtBoxAmount"

But if the next record is companyNumber 222

both "labelCompany" and "txtBoxAmount" will not display.

any tips will be appreicated. Thank you in advance.

Cheers
 
G

GeoffG

You don't specifically say you want to display the label and
textbox on an Access report if certain conditions are true, but,
as you're posting to an Access Reports newsgroup, I assume that's
your objective.

Therefore, see:

http://msdn.microsoft.com/en-us/library/aa165406(office.10).aspx

The Format event requires a macro or some Visual Basic for
Applications (VBA) code. (VBA code gives you easier control over
what you want to do.)

As the Format event has access to the data in the current record
(as the report is being formatted), you can examine the value in
the companyNumber field for each record (while Access formats the
report): if the value is 111, you can set the Visible property of
the label and the textbox to True; and if the value is anything
else, you can set the Visible property to False.

For example, your code for the Format Event of the Detail Section
of the report might be something like:

Me.lblCompany.Visible = (Me.companyNumber = 111)
Me.txtBoxAmount.Visible = (Me.companyNumber = 111)

Search help for more information on the Format Event.

Regards
Geoff
 

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