I figure there may be an easy solution for this one:
I'm trying to add new records using a form with text and combo boxes. On the form's On_Load event, I using the command DoCmd.GoToRecord , , acNewRec to prepare for new record entry first, thus clearing the controls.
Data is entered into the controls, then the user clicks the cmdSave button which initiates the code below. However, unless the user clicks elsewhere after filling in the last text box control, etc., the form does not recognize that data was actually entered into the final control. The user receives the message from the save code to "Please fill in all required fields."
I'm trying to add new records using a form with text and combo boxes. On the form's On_Load event, I using the command DoCmd.GoToRecord , , acNewRec to prepare for new record entry first, thus clearing the controls.
Data is entered into the controls, then the user clicks the cmdSave button which initiates the code below. However, unless the user clicks elsewhere after filling in the last text box control, etc., the form does not recognize that data was actually entered into the final control. The user receives the message from the save code to "Please fill in all required fields."
Code:
'test required fields
If IsNull(Me.txtVehicleID.Value) _
Or IsNull(Me.cboVehicleNum.Value) _
Or IsNull(Me.txtODate.Value) _
Or IsNull(Me.txtFuel.Value) _
Or IsNull(Me.txtOdometer.Value) Then
MsgBox "Please fill in all required fields."
Else
MsgBox "Record saved."
'Requery forms
Me.Requery
Me.Parent.frmMileageDetail.Form.Requery
' Prepare form for new record input
DoCmd.GoToRecord , , acNewRec
End If