Hello All...
I have been struggling to solve an issue with a multi-condition IF statement. If anyone has any ideas, I would certainly appreciate hearing them.
Here is the situation: MS Access 2010. Unbound form, unbound text and combo boxes.
4 controls: (me.tb1), (me.tb2), (me.cmb1) and (me.cmb2)
Me.tb1 can be blank, numeric, or alpha-numeric. Me.tb2 can be blank, numeric, or alpha-numeric.
Me.cmb1 and me.cmb2 are combo boxes with numerous text selections available to the user.
Condition1: I want to pop msg1 if me.tb1 is alpha-numeric AND me.tb2 is blank, and me.cmb1 <>”Select1” OR me.cmb2 <> “Select2”. I think the problem here is, the condition passes if me.tb1 is blank, because blank is also not alpha-numeric. If me.tb1 is blank, and me.cmb1 OR me.cmb2 are the correct text, then the condition should pass, i.e move on to next test. I only want to pop the message if me.tb1 is alpha-numeric and me.tb2 is blank and me.cmb1 and/or me.cmb2 <> "Select1" or "Select2" combo-box selection.
Condition2: I also need to pop msg2 (different message) if me.tb1 is blank, and me.cmb1 <>”Select3” OR me.cmb2 <>”Select4”. (here I don't care what is in me.tb2)
I need them to test in that order, i.e. test for condition1, then test for condition2. If Condition1 fails, it loops the user back until Condition1 passes, then moves on to test for Condition2.
I have code working for Condition2, and I can get Condition1 to work for 1 condition but not the others at the same time (i.e blank, numeric, and alpha-numeric). I just can’t seem to get it working for all conditions. I test for these conditions just before the open-recordset action. Both the conditional testing and the saving of the record is currently in the same private sub, triggered by a “Save” (on-click event) button on the form.
Any help would certainly be appreciated. Sorry I can't post the actual code I'm using due to Chinese wall at work. They have everything locked down pretty tight, I can't even copy and paste when working remotely.
I have been struggling to solve an issue with a multi-condition IF statement. If anyone has any ideas, I would certainly appreciate hearing them.
Here is the situation: MS Access 2010. Unbound form, unbound text and combo boxes.
4 controls: (me.tb1), (me.tb2), (me.cmb1) and (me.cmb2)
Me.tb1 can be blank, numeric, or alpha-numeric. Me.tb2 can be blank, numeric, or alpha-numeric.
Me.cmb1 and me.cmb2 are combo boxes with numerous text selections available to the user.
Condition1: I want to pop msg1 if me.tb1 is alpha-numeric AND me.tb2 is blank, and me.cmb1 <>”Select1” OR me.cmb2 <> “Select2”. I think the problem here is, the condition passes if me.tb1 is blank, because blank is also not alpha-numeric. If me.tb1 is blank, and me.cmb1 OR me.cmb2 are the correct text, then the condition should pass, i.e move on to next test. I only want to pop the message if me.tb1 is alpha-numeric and me.tb2 is blank and me.cmb1 and/or me.cmb2 <> "Select1" or "Select2" combo-box selection.
Condition2: I also need to pop msg2 (different message) if me.tb1 is blank, and me.cmb1 <>”Select3” OR me.cmb2 <>”Select4”. (here I don't care what is in me.tb2)
I need them to test in that order, i.e. test for condition1, then test for condition2. If Condition1 fails, it loops the user back until Condition1 passes, then moves on to test for Condition2.
I have code working for Condition2, and I can get Condition1 to work for 1 condition but not the others at the same time (i.e blank, numeric, and alpha-numeric). I just can’t seem to get it working for all conditions. I test for these conditions just before the open-recordset action. Both the conditional testing and the saving of the record is currently in the same private sub, triggered by a “Save” (on-click event) button on the form.
Any help would certainly be appreciated. Sorry I can't post the actual code I'm using due to Chinese wall at work. They have everything locked down pretty tight, I can't even copy and paste when working remotely.