Jeff Bridgham showed me the following code in a thread where I asked
"I have a form and it has about four fields. Filenumber, last name, first name. What I want to do is if one or more of these fields are blank when the user tries to add a new record or to save the current one, I want a msgbox to appear stating which fields need to be completed."
A msgbox does appear with "needs to be filled in" but it is not displaying what fields need to be filled in, it is somehow not adding the needed fields to the list. Can someone tell me what is wrong with the code below that is not enabling it to work. I'm a newbie and I have no idea what to look for. Thanks
Dim Msg As String
Dim cntl As Control
Msg = ""
For Each cntl In Me.Controls
If cntl.ControlType = acTextBox Then
If IsNull(cntl.Value) = True Then
Msg = Msg & cntl.Value & " "
End If
End If
Next cntl
If Msg = "" Then
Msg = "All fields are correct"
Else
Msg = Msg & "need to be filled in."
End If
Call MsgBox(Msg)
"I have a form and it has about four fields. Filenumber, last name, first name. What I want to do is if one or more of these fields are blank when the user tries to add a new record or to save the current one, I want a msgbox to appear stating which fields need to be completed."
A msgbox does appear with "needs to be filled in" but it is not displaying what fields need to be filled in, it is somehow not adding the needed fields to the list. Can someone tell me what is wrong with the code below that is not enabling it to work. I'm a newbie and I have no idea what to look for. Thanks
Dim Msg As String
Dim cntl As Control
Msg = ""
For Each cntl In Me.Controls
If cntl.ControlType = acTextBox Then
If IsNull(cntl.Value) = True Then
Msg = Msg & cntl.Value & " "
End If
End If
Next cntl
If Msg = "" Then
Msg = "All fields are correct"
Else
Msg = Msg & "need to be filled in."
End If
Call MsgBox(Msg)