Private Sub cmdSubmit_Click() Dim strFieldNames As String If Me.txtFirstName.Text = "" Then strFieldNames = "First Name" End If If Me.txtLastName.Text = "" Then strFieldNames = strFieldNames & vbcrlf & "Last Name" End If 'if field is empty, alert user which field is empty If strFieldNames <> "" Then MsgBox "Missing Information: " & strFieldNames else 'do you submit stuff here End If End SubBTW, in your previous code, the declaration is at the wrong place. It should be in the General Declarations section (and not in the form load). Add "Option Explicit" at the top of your code and you will get an error related to that variable.
>==================================================== >Private Sub Form_Load() > >'create variable to store field name > Dim strFieldName As String > >End Sub >==================================================== >Private Sub txtFirstName_Change() > >'store the textbox name, used for cmdSubmit > If Me.txtFirstName.Text = "" Then > strFieldName = "First Name" > Else > strFieldName = "" > End If >End Sub >==================================================== >Private Sub cmdSubmit_Click() > >'if field is empty, alert user which field is empty > If Not strFieldName = "" Then > MsgBox "Missing Information: " & strFieldName > End If > >End Sub >==================================================== >>