Tickbox Update

B

Bateman28

Hi hope someone can help

I have a form with lots of differnt tickbox options. What i want to do is
have a routine so that when two options are ticked Or to the value true, a
specific field then becomes ticked. The code i have tried is below, Any help
would be greatly appreciated

If Me.***CampaignMail = -1 And Me.***vice = -1 Then
Me.*****Booking = -1
Else
Me.*****Booking = 0
End If

The Stars represent letters!
 
D

Daryl S

Bateman28 -

The code looks OK, where did you put it (e.g. what events make the code
run)? Have you stepped through it? I assume the three fields are boolean
(Yes/No) datatypes?

You may want code like this in a form subroutine that can be called from
several events depending on when you want the validation / updates to take
place. Then you can put the call to the subroutine behind the click events
of any of the check boxes and maybe on the form's OnCurrent event, and
probably on the form's BeforeUpdate event.
 
B

Bateman28

The code has been applied to the "After Update" command, and yes the fields
are tick boxes as boolean....Any other idea's??
 
A

Amy E. Baggott

You might want to replace -1 and 0 with True and False since they are boolean
values. Also, is it in the AfterUpdate property of the form or of one of the
fields?
 
B

Bateman28

Hi thanks for the reply,

The "After Update" is on the field that contains the first part of code
within my form. I have also tried to use the code with "True & False" values
rather than "-1 Or 0's"!

I Tried Another way like shown below but that didnt work either! Arrrrrrrrr!
Any more idea's would be greatly appreciated!

Private Sub ***CampaignMail_AfterUpdate()

If Me![***CampaignMail] = -1 And Me![Service] = -1 Then
Me![*****Booking] = -1
Else
Me![*****Booking] = 0
End If

End Sub
 
D

Daryl S

Have you stepped through the code? Is it executing (put a breakpoint in)?
If it is executing, then are the values for Me![***CampaignMail] and
Me![Service] correct? If it is not executing, then are you changing the
values in Me![***CampaignMail] or Me![Service]?

--
Daryl S


Bateman28 said:
Hi thanks for the reply,

The "After Update" is on the field that contains the first part of code
within my form. I have also tried to use the code with "True & False" values
rather than "-1 Or 0's"!

I Tried Another way like shown below but that didnt work either! Arrrrrrrrr!
Any more idea's would be greatly appreciated!

Private Sub ***CampaignMail_AfterUpdate()

If Me![***CampaignMail] = -1 And Me![Service] = -1 Then
Me![*****Booking] = -1
Else
Me![*****Booking] = 0
End If

End Sub
Amy E. Baggott said:
You might want to replace -1 and 0 with True and False since they are boolean
values. Also, is it in the AfterUpdate property of the form or of one of the
fields?
 

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