Validate form

oumahexi

Free Range Witch
Local time
Today, 00:43
Joined
Aug 10, 2006
Messages
1,996
Hi guys

I currently have a form that gathers scores in two ways, one column listed A-F and the other 1-4, so a student can get for instance A1; A2; A3, A4, B1 etc.

At the moment the fields are set up with a validation rule which means that a validation check is run after each character is typed in.

The problem is that the end users are finding this to be a long and laborious task and I have been asked to change the validation so that the rule runs on close. As there are three tabs to the form, each gathering similar codes about different subjects, it's not as simple as selecting on close, is it?

Any suggestions?
 
Hi - could be as simple as on close, I have a similar thing in one of my databases where i have a close button to close the form and return to the previous form, which uses the following code

Code:
Dim stMessage As String
   

    stMessage = ""
    If Nz(Me![cboCondition], "") = "" Then stMessage = "Condition" & vbCrLf
    If Nz(Me![cboReferralReason], "") = "" Then stMessage = stMessage & "Treatment Requested" & vbCrLf
    If Nz(Me![txtRequestReason], "") = "" Then stMessage = stMessage & "Details of Request" & vbCrLf
    If Nz(Me![Request Date], "") = "" Then stMessage = stMessage & "Request Date" & vbCrLf
    If Nz(Me![Administrator], "") = "" Then stMessage = stMessage & "Administrator Name" & vbCrLf
    
    
    If stMessage <> "" Then
        MsgBox "You need to enter the following:" & vbCrLf & vbCrLf & stMessage, vbExclamation, "Mandatory Information Missing!"
        Me.cboReferralReason.SetFocus
    Else
    DoCmd.Close
    
    
    End If

Obviously in mine i am checking for Null values as i want to ensure certain fields are completed, when a user exits, as there are null values in some of the historic data - i want to ensure that users are forced to update the required ones prior to leaving the record, you could simply adapt and insert your conditional checks where needed.

Hope this helps

Ian
 
Hi - could be as simple as on close, I have a similar thing in one of my databases where i have a close button to close the form and return to the previous form, which uses the following code

Code:
Dim stMessage As String
   

    stMessage = ""
    If Nz(Me![cboCondition], "") = "" Then stMessage = "Condition" & vbCrLf
    If Nz(Me![cboReferralReason], "") = "" Then stMessage = stMessage & "Treatment Requested" & vbCrLf
    If Nz(Me![txtRequestReason], "") = "" Then stMessage = stMessage & "Details of Request" & vbCrLf
    If Nz(Me![Request Date], "") = "" Then stMessage = stMessage & "Request Date" & vbCrLf
    If Nz(Me![Administrator], "") = "" Then stMessage = stMessage & "Administrator Name" & vbCrLf
    
    
    If stMessage <> "" Then
        MsgBox "You need to enter the following:" & vbCrLf & vbCrLf & stMessage, vbExclamation, "Mandatory Information Missing!"
        Me.cboReferralReason.SetFocus
    Else
    DoCmd.Close
    
    
    End If

Obviously in mine i am checking for Null values as i want to ensure certain fields are completed, when a user exits, as there are null values in some of the historic data - i want to ensure that users are forced to update the required ones prior to leaving the record, you could simply adapt and insert your conditional checks where needed.

Hope this helps

Ian


thanks Ian, that did help, although my biggest problem was that the on close event had been replaced with a cmdback event, once I found that it was full steam ahead. Your help was much appreciated.
 

Users who are viewing this thread

Back
Top Bottom