Set up Alert

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to set up an alert on a form. If the user does not fill out all the
fields, they are prompted with a message - "You cannot continue until all the
fields are complete."
How can this be accomplished?

Thank you
 
Natalia,

This can be accomplisehd by checking the .Value of each control in an event.

In the "Form Unload event" you can put code to check the value of each
control & then set the Form Property of "Cancel" = true so the form wont
unload.

So for example....

Private Sub Form_Unload(Cancel As Integer)

Cancel = False
If NameTextBox1="" then Cancel = True
If NameTextBox2="" then Cancel = True
If NameTextBox2="" then Cancel = True
If NameTextBox3="" then Cancel = True

' etc. put a check in for each control.

if Cancel = true then Msgbox "You cannot continue until all the fields are
complete."

End Sub


Regards,
Jeff
 
I want to set up an alert on a form. If the user does not fill out all the
fields, they are prompted with a message - "You cannot continue until all the
fields are complete."
How can this be accomplished?

Thank you

Why not set a validation rule for each of the controls:
Is Not Null

Or...
You can code the Form's BeforeUpdate event:

Dim c As Control
Dim intX As Integer

For Each c In Me.Section(0).Controls
If TypeOf c Is TextBox Or TypeOf c Is ComboBox Then
If IsNull(c) Then
intX = 1
Exit For
End If
End If
Next c

If intX = 1 Then
MsgBox "You cannot continue until all the fields are complete."
Cancel = True
End If

You may need to add listboxes, checkboxes, etc., to the TypeOf
statement above, if appropriate.
 
Back
Top