Report "On-Format" event (1 Viewer)

Jonny45wakey

Member
Local time
Today, 11:23
Joined
May 4, 2020
Messages
40
Hi All

I have a report "rptInvoice" that has an If statement within the detail section of the report which is in the "on-format" event; however its not working correctly and i dont know why?

In essence, when the report loads it should have either a "YES" or "NO" in the field "RCV", this is populated by a form and works for the "YES" but not for the "NO

The "on-format" code is as follows, how can i ensure that if the field "RCV" on the report is "NO" the code is executed?

1674126452193.png


Thanks for any help

Jonny
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:23
Joined
Feb 19, 2013
Messages
16,616
Are you sure the rcv control contains a text value and not a Boolean value
 

Jonny45wakey

Member
Local time
Today, 11:23
Joined
May 4, 2020
Messages
40
Are you sure the rcv control contains a text value and not a Boolean value
Thanks CJ_London, it was a text value but I stepped through the form properties which drive the report and the "RCV" control source wasn't assigned to "RCV" it was blank and hence the report "RCV" field was always blank, its working now the control source is assigned correctly

Hope that makes sense?

Thanks for your support :)

JOnny
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:23
Joined
Feb 19, 2013
Messages
16,616
Happy to help

for the future, please post code as text, highlight and click the >_ button to apply code tags. Makes it easier for users to copy/paste code for responses.

Also get used to indenting code, makes it much easier to read

Assuming you RCV value should only be 'yes' or' 'no then you could simplify your code to

label1211.visible = RCV="yes"
label1212.visible = RCV="yes"
etc

just 5 lines of code rather than 14 - no need for the if's, no need for Me., no need for .value
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:23
Joined
Feb 19, 2002
Messages
43,293
The code should NOT be two separate If statements. It should be:
If ... Then
....
Else
....
End If
 

Users who are viewing this thread

Top Bottom