ValidationRule Help

maxxximaniac

Registered User.
Local time
Today, 07:43
Joined
Oct 22, 2004
Messages
80
Hey Guys,

I Have a combo field, ComboFunction, where if the value = "Misc" then a memo field appers, txtMemo.

txtMemo must not be null if ComboFunction = "Misc".

I am not sure where to put this event code or how the proper way it would be written.
It must be in the form and not the table, as its only required when ComboFunction = "Misc"

Any Ideas?
You're help is much appreciated.
Thanks!
 
If the memo field is to been stored at all, then it must exist in the table.

You can ensure that it is only displayed, however, when ComboFunction is not null.

Use the AfterUpdate event of ComboFunction to check for null, and then toggle the visibility of the txtMemo.

Code:
Private Sub ComboFunction_AfterUpdate()

    If Me.ComboFunction= "Misc" Then
        Me.txtMemo.Visible = True
    Else
        Me.txtMemo.Visible = False
    End If

End Sub

Now, you also must verify that the txtMemo is not Null when leaving the record. If it is, then set the cancel to true and Access will return to the record.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    MsgBox "Before Update"
    
    If Me.ComboFunction = "Misc" Then
        If IsNull(Me.txtMemo) Then
            MsgBox "You must enter a memo"
            Cancel = True
        End If
    End If
    
End Sub

- g
 
Great, worked like a charm,
Thank you! :)
 

Users who are viewing this thread

Back
Top Bottom