Display a message when a field is blank

jeo

Registered User.
Local time
Today, 19:10
Joined
Dec 26, 2002
Messages
299
On my form i have a couple of fields that shouldn't contain a Null value.
I can't seem to figure out where to put my code with displaying a msgbox if a value is null. I tried the Before_Update event, but nothing ever happens.

I want this msgbox to pop up right after a field is bypassed and not filled out.
Dim strMsg As String, strTitle As String
Dim intStyle As Integer

If IsNull(Me!Combo0) Or Me!Combo = "" Then
strMsg = "You must pick a project."
strTitle = "Project Name Required"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Cancel = True
End If
Any ideas?
Thanks!
 
Last edited:
Hi Jeo

On the Before Update event of your control put something like:
Code:
Private Sub YOURCONTROL_BeforeUpdate(Cancel As Integer)
' Display message if  combo box is blank

    Dim strMsg As String, strTitle As String
    Dim intStyle As Integer
    
    If IsNull(Me!CONTROLNAME) Or Me!CONTROLNAME = "" Then
        strMsg = "You must pick a value from the ' Combo List."
        strTitle = "Field Required"
        intStyle = vbOKOnly
        MsgBox strMsg, intStyle, strTitle
        Cancel = True
    End If
End Sub

Hope this helps,
Phil.
 
You will have to use the forms BeforeUpdate event, if a user does not tab through your control then the code will not fire from that controls BeforeUpdate event
 

Users who are viewing this thread

Back
Top Bottom