I have a submit records cmdButton.
As shown in the code below it updates the opened record in the SQL BE DB. How can I get it to clear all the values from the form, to enable me to input a new record.
I have tried
Me.txtNHSNo = ""
Me.txtNHSNo.Value = NULL
Me.txtNHSNo.Value = ""
and these all dont work, as when click cmdButton to create new record it doesnt allow it. The error message I get it
'The Value you entered doesnt meet the validation rule defined for the field or control' What does this mean?
As shown in the code below it updates the opened record in the SQL BE DB. How can I get it to clear all the values from the form, to enable me to input a new record.
I have tried
Me.txtNHSNo = ""
Me.txtNHSNo.Value = NULL
Me.txtNHSNo.Value = ""
and these all dont work, as when click cmdButton to create new record it doesnt allow it. The error message I get it
'The Value you entered doesnt meet the validation rule defined for the field or control' What does this mean?
Code:
Private Sub cmdSubmit_Click()
Dim varResponse As Variant
Dim sQRY As String
Dim rs As DAO.Recordset
Dim intNHSNo As Long
'**************************************
' On Error GoTo Err
varResponse = MsgBox("Save Changes?", vbYesNo, cApplicationName)
If varResponse = vbNo Then
Me.Undo
Exit Sub
End If
'**************************************
sQRY = "UPDATE jez_SWM_Visits " & _
"SET [NHSNo] = '" & Me.txtNHSNo & "', [Surname] = '" & Me.txtSurname & "', [Forename] = '" & Me.txtForename & "', [Gender] = '" & Me.cboGender & "', [Address1] = '" & _
Me.txtAddress1 & "', [Address2] = '" & Me.txtAddress2 & "', [Address3] = '" & Me.txtAddress3 & "', [Postcode] = '" & Me.txtPostcode & "', [Telephone] = '" & _
Me.txtTelephone & "', [DateOfBirth] = '" & Me.txtDOB & "', [ReferralReasonDescription] = '" & Me.cboReferralRsn & "', [SourceDescription] = '" & _
Me.cboReferralSource & "', [DateOfReferral] = '" & Me.txtReferralDate & "', [VisitDate] = '" & Me.txtVisitDate & "', [OpenorClosed] = '" & Me.chkFinalVist & "'," & _
"[Weight] = '" & Me.txtWeight & "', [Height] = '" & Me.txtHeight & "', [BMI] = '" & Me.txtBMI & "', [BloodPressure] = '" & Me.txtBlood & "', [ExerciseLevel] = '" & _
Me.txtExercise & "', [DietLevel] = '" & Me.txtDiet & "', [SelfEsteem] = '" & Me.txtSelf & "', [WaistSize] = '" & Me.txtWaist & "', [Comments] = '" & _
Me.txtComments & "', [SessionType] = '" & Me.cboSessionType & "', [NHSStaffName] = '" & Me.txtStaffName & "', [Arrived] = '" & Me.cboAttendance & "', " & _
"[ActiveRecord] = -1, [InputBy] = '" & fOSUserName & "', [InputDate] = '" & VBA.Now & "', [InputFlag] = -1 " & _
"WHERE jez_SWM_Visits.VisitID = Forms!frmVisits!txtVisitID "
DoCmd.RunSQL sQRY
Me.lblBMIInfo.Visible = False
Me.txtDummy.SetFocus
Me.txtNHSNo = ""
'All other TextBox and Combo are here taken out for this
'Err:
' basError.LogError VBA.Err, VBA.Error$, "Form_frmMain - cmdSubmit_Click()"
End Sub