Conditional Validation Rule

kanchan

Registered User.
Local time
Today, 15:54
Joined
Dec 8, 2014
Messages
10
I am trying to implement a validation rule in a text box named PHOTO_ID_NUMBER which will depend on a value in Combo546,but my vba code for after update is not working.
my code was to check:

If Me.Combo546 selection was "National ID" Then check

If Len(Me.PHOTO_ID_NUMBER) = 13 Or Len(Me.PHOTO_ID_NUMBER)= 17 or else
MsgBox "Enter a value either 13 or 17 digits "

one more thing, the record moves to new one although ( is not null) validation rule is applied in all the field.

thanks in advance for your help.
 

Attachments

Don't put it in the validation rule instead write a validation function to check before you can leave the record...

'user clicks save button, save_OnClick event
Code:
 '------------
 sub btnSave_OnClick
 '------------
   if IsValidForm() then
       'save record and move on
   end if
 end sub
  
 '------------
 public Function IsValidForm() as boolean
dim vMsg
   select case true
       case Me.Combo546 = "National ID" 
         
            If Len(Me.PHOTO_ID_NUMBER) = 13 Or Len(Me.PHOTO_ID_NUMBER)= 17 then
           else
            vMsg = "Enter a value either 13 or 17 digits "
          endif
        case isnull(cboState )
          vMsg = "State is missing"
   cboState.setfocus
   end select
 
  if vMsg <>"" then msgbox vmsg,vbCritical,"Required"
  IsValidForm =vMsg =""
end function
 
Employee Clock IN/OUT

Dear forum,

i m in need of help of creating a connection in between my excel main screen punch in and punch out button with the access database[where excel will be front end and access db will be back end]as the excel table is not feasible for multiple people to log in at the same time in excel even if it is shared.my excel admin password is '2017'.eagerly waiting for your help.

thanks and regards.
 

Attachments

Users who are viewing this thread

Back
Top Bottom