Open another form if checkbox is checked

Hey Lucy

Registered User.
Local time
Today, 02:05
Joined
Jan 20, 2012
Messages
124
I am trying to write an IF statement as a macro on the OnClick property of a checkbox and can't get it to work, so I'm looking for help or even suggestions of a better way to accomplish this, if it can even be done. I don't see why it can't.

Basically, if the checkbox is checked (for Yes) I want it to open another form. (The checkbox is a field on a subform on a form).

I haven't even gotten this far yet, but I would also like the IF statement to include an AND somehow....in other words I want the IF statement to basically say if the box is checked for yes AND the offer status field ="Accepted", then open another form. If either is False, then I don't want it to do anything except display a message box saying they can't initiate a contract is both conditions aren't true.

I have attached a screenshot of the macro.

Thanks in advance!
 

Attachments

  • Screenshot On Click Macro.jpg
    Screenshot On Click Macro.jpg
    92.2 KB · Views: 1,250
With regards the error, you just need to state

Code:
 If [ContractCheckBox]=Yes Then

To include the And then it would be

Code:
 If [ContractCheckBox]=Yes AND [OfferStatus] = 'Accepted' Then

I don't usually use Yes - the standard usage is to use True (or False)

I don't use macros so not sure how you would include the 'and' in that context, but I would presume there is a way. If not then you could alsways use an nested if statement

Code:
 If [ContractCheckBox]=Yes THEN
    IF [OfferStatus] = 'Accepted' Then
        openform
    else
        msgbox
    end if
end if
 
Thank you CJ...I didn't think o f nested If statements. Gonna give that a try. Can you tell I have an Excel background? LOL. I can easily do If statements in Excel with an AND but wasn't sure in Access and couldn't make it work.
 

Users who are viewing this thread

Back
Top Bottom