If (1 Viewer)

mike60smart

Registered User.
Local time
Today, 04:30
Joined
Aug 6, 2017
Messages
1,908
Hi Everyone

I have an Invoice type report with one of the Controls named "TaxExempt"

If this Control has a value of "Yes" I want the following to happen

Code:
If Me.TaxExempt = "Yes" Then
Me.T.Visible = True
Me.Notice.Visible = True
Else
Me.T.Visible = False
Me.Notice.Visible = False
End If

Where would it be best to place this code?

Edit **

I placed the code in the On Open event of the form and I now get the following error

When I hit Debug it highlights this line

If Me.TaxExempt = "Yes" Then
 

Attachments

  • error.PNG
    error.PNG
    3.9 KB · Views: 57
Last edited:

isladogs

MVP / VIP
Local time
Today, 04:30
Joined
Jan 14, 2017
Messages
18,209
As its a report, place it in the On Format event of the section where the control is located e.g. Detail_Format
Note that will only have an effect when the report is in print preview or actually printed
 

NauticalGent

Ignore List Poster Boy
Local time
Yesterday, 23:30
Joined
Apr 27, 2015
Messages
6,321
Good morning. I would think the OnLoad event would be the best place to put this code.
 

NauticalGent

Ignore List Poster Boy
Local time
Yesterday, 23:30
Joined
Apr 27, 2015
Messages
6,321
Apologies, I did not see that Col has responded. That being said, he is much more familiar with report events than I am. I would try his suggestion first!
 

mike60smart

Registered User.
Local time
Today, 04:30
Joined
Aug 6, 2017
Messages
1,908
Hi Colin

Now that is strange

I placed the code in the On Format of the Form and now when the Control Tax Exempt value = Yes all of my Total Calculations display as follows:-

And when the Tax Exempt value = No all the calulations work as normal ?
 

Attachments

  • Now displays.PNG
    Now displays.PNG
    2.9 KB · Views: 52
  • When No.PNG
    When No.PNG
    3 KB · Views: 53

isladogs

MVP / VIP
Local time
Today, 04:30
Joined
Jan 14, 2017
Messages
18,209
You originally said it was a report and my answer was based on that.
Now you mention a form. Which is it?
 

June7

AWF VIP
Local time
Yesterday, 19:30
Joined
Mar 9, 2014
Messages
5,465
If this is a report:

Place code in Format event of section where data is located. Is TaxExempt a text or yes/no field?

Format event only triggers for direct to printer or PrintPreview, not ReportView.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 04:30
Joined
Jan 14, 2017
Messages
18,209
OK - what report view are you using?
Also as asked by June, what datatype is field TaxExempt?
 

mike60smart

Registered User.
Local time
Today, 04:30
Joined
Aug 6, 2017
Messages
1,908
Hi Colin

That works just great when I managed to locate the Format option

Many thanks yet again
 

Users who are viewing this thread

Top Bottom