Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with check box's

Status
Not open for further replies.

jazzz

Technical User
Feb 17, 2000
433
US
BeforeUpdate of a form I have two check boxes called purchased and sold if either is checked I need to check two fields associated with each check box (4 FIELDS IN ALL) to see if they are blank and if so undo and exit. I just can't get it to check the both correctely.<br><br>If purchased is checked and BOTH associated fields have their data in then save and exit.<br><br>If sold is checked and Both associated fields have their data in then save and exit. <br><br>What's happening is it checks the first If and I'm done or If a field for purchased is blank but I'm only checked on sold it's telling me I have a blank field. I need to get my If or ElseIf correct.<br><br>Thanks<br>Myron
 
If purchased = yes AND (not isnull(Field1) AND not isnull(Field2) then<br>&nbsp;&nbsp;&nbsp;' Save<br>Else<br>&nbsp;&nbsp;&nbsp;' Undo<br>EndIf<br><br>and do the same for the other check box,<br><br>Hope this would help YOU...<br><br> <p>Mohamed Aly<br><a href=mailto:samara_79@hotmail.com>samara_79@hotmail.com</a><br><a href= > </a><br>
 
Thank you, but that's exactly what I am using but if only one control has data the expression is no longer true and allows a user to save with invalid data.
 
Just nest the If's<br><br>Note: To test if a boolean (check box) is true, you do not need to say = yes, you can just simply test for that boolean (check box). for example:<br><br>If Me.Purchased AND (Not IsNull(Field1) AND Not IsNull(Field2)) Then<br>&nbsp;&nbsp;&nbsp;If Me.Sold AND (Not IsNull(Field3) AND Not IsNull(Field4)) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' Save<br>&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' Undo<br>&nbsp;&nbsp;&nbsp;End If <br>Else<br>&nbsp;&nbsp;&nbsp;' Undo<br>End If <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
Had you though about the space factor?&nbsp;&nbsp;If there is a space there it is not null correct so you need to code for spaces!
 
Hi <br><br>could try <br><br>if me.Purchased then<br>'purchased selected<br>&nbsp;&nbsp;&nbsp;if isnull(me.field1) Or isnull(me.field2) then<br>&nbsp;&nbsp;&nbsp;&nbsp;'either/both the fields are null <br>&nbsp;&nbsp;&nbsp;&nbsp;'undo<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;'save<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>else<br>'sold selected (assume they are grouped)<br>&nbsp;&nbsp;&nbsp;if isnull(me.field3) Or isnull(me.field4) then<br>&nbsp;&nbsp;&nbsp;&nbsp;'either/both the fields are null <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;undo<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;save<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br><br>end if<br>the space factor may also be a gotcher<br><br>hope this helps<br><br>RobertD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top