Hope you can help me with this
I run Access2000 on XP
Form has 3 fields:
- cboSTATUS - which can be set via Limited value List A B or Complete. Default is set as A.
cboTHIS - which can be set via Limited Value List X, Y or Z. No Default. Intiially field in blank (Null).
txtTHAT - which can be anything. No Default text. Intiially field in blank (Null).
SCENE1: User goes to work on a record and initially all 3 fields are set as above (A, Null and Null).
The User sets cboStatus as Complete and attempts a Save/Close of the record.
I then run validations to ensure the other 2 fields have valid data for a Completed cboStatus setting.ie:
- cboTHIS - cannot be Y or Null, but can be X or Z.
txtTHAT - cannot be blank
If an ivalid entry is detected in THIS or THAT, msg box pops up and SaveClose action cancelled.
I set the validation arguments as:
If IsNull(Me.cboTHIS) Or Me.cboTHIS = "" Or Me.cboTHIS = "Y" And Me.cboStatus = "Completed" Then
MsgBox etc.....
ElseIf IsNull(Me.cboTHAT) Or Me.cboTHIS = "" And Me.cboStatus = "Completed" Then
MsgBox etc.....
I thought this worked a charm. I tested by having both THIS and THAT wrong, or both right, or one wrong, one right. Validation code worked as desired.
I tested by having THIS and THAT either wrong or right, with cboStatus set as A and as as expected, Save was actioned (because no Validation rule was broken since cboStatus was not set as Completed)
SCENE2: However I have found - if User later comes BACK into the record, after it passed the above validations.
Then changes
- cboStatus to A
changes cboTHIS to Y
changes txtTHAT to nothing (Null, "")
and tries to SaveClose, the Validation code runs, and act as if the cboStatus is set as Completed. ie. it says THIS cannot be Y and THAT cannot be Null. I want , in this case to accept the save, because cboStatus is not set as Complete!
I think it's the Or bit in the argument? Because if I take that out, and have just the following, I have no problem with SCENE2. ie The User can save the form as it's been edited:
If IsNull(Me.cboTHIS) And Me.cboStatus = "Completed" Then
MsgBox etc....
Am I missing ( )or [ ] or ! or all, in crucial places?.
Hope this is not too confusing (you should be in my side of the screen :-))
Thanks for all help!
Cheers
AMBLY