VBA Checkbox code ticking all records on report. How to target individual records?

Garindan

Registered User.
Local time
Today, 11:07
Joined
May 25, 2004
Messages
250
Sorry for the long title.

I have the following code in the On Load of a report which shows multiple records:-

Code:
If Me.PaymentType Like "Debit/Credit Card" Then
    Me.Check94 = True
Else
    Me.Check94 = False
End If

This ends up checking all check boxes in the report if any have "Debit/Credit Card" in the PaymentType field.

What I wanted was to tick Checkboxes for those records where the statement was true, and not tick those where it is false.

Do I need the code in the On Current event? Or do I need more sophisticated code?

Many thanks for your help!
 
You need to use the correct event. If you want something to affect each row as it prints, use the Format event.

Also, don't use LIKE unless you have an incomplete string and are using wildcard characters for the missing parts. When you have a complete string, use =.
 
I think you can skip the code entirely, if what I understand of what you want is accurate.

In the query behind the report, put in a calculated field:
Code:
PaidByCard: IIF([PaymentType] = "Debit/Credit Card", True, False)
Then in your report, just put a checkbox based on that calculated field, and you should be good to go.
 
Brilliant. Thankyou to both of you! I have used Davids method and it's working perfectly. Thanks again!
 

Users who are viewing this thread

Back
Top Bottom