A
an
Hello!
I have a form to add mew records in a table.
I would like a code in Before Update, through message box,
for:
1 - If the user click to close the form with any field
without data, the MsgBox alert to the empty field name;
2 - The user will be able to continue or to leave;
3 - If to continue, the cursor to get off field;
4 - If all fields they will be filled, save and close.
I have the next code but don't work fine.
Dim strField As String
Dim vFields As Variant
Dim i As Integer
Dim strMsg As String
vFields = Split("Field1,Field2,Field3")
For i = 0 To UBound(vFields, 1)
If IsNull(Me(vFields(i))) = True Then
strField = vFields(i)
Exit For
End If
Next i
If strField <> "" Then
If strMsg = strField + "Empty data" & vbCrLf & "Do you
insert data?" Then
If MsgBox(strField, vbYesNo + vbExclamation, "To
whrite data") = vbYes Then
Me(strField).SetFocus
Cancel = True
DoCmd.RunCommand acCmdUndo
Else
Me.Undo
End If
End If
End If
I would like your help for this.
Thanks in advance.
an
I have a form to add mew records in a table.
I would like a code in Before Update, through message box,
for:
1 - If the user click to close the form with any field
without data, the MsgBox alert to the empty field name;
2 - The user will be able to continue or to leave;
3 - If to continue, the cursor to get off field;
4 - If all fields they will be filled, save and close.
I have the next code but don't work fine.
Dim strField As String
Dim vFields As Variant
Dim i As Integer
Dim strMsg As String
vFields = Split("Field1,Field2,Field3")
For i = 0 To UBound(vFields, 1)
If IsNull(Me(vFields(i))) = True Then
strField = vFields(i)
Exit For
End If
Next i
If strField <> "" Then
If strMsg = strField + "Empty data" & vbCrLf & "Do you
insert data?" Then
If MsgBox(strField, vbYesNo + vbExclamation, "To
whrite data") = vbYes Then
Me(strField).SetFocus
Cancel = True
DoCmd.RunCommand acCmdUndo
Else
Me.Undo
End If
End If
End If
I would like your help for this.
Thanks in advance.
an