Solola
Board Regular
- Joined
- Sep 23, 2003
- Messages
- 73
I have a data-form and I have vba (2 separate if statements) to assess 2 date fields to determine if data entry can continue. Essentially, if both date fields are "n/a", or if the cancel_date is n/a and the appt_date is in the future, I want to throw an error and clear the form. My problem is that my vba is clearing the form regardless of the outcome of the if statements. Even if both dates are in the past, I'm stilling getting my message and a cleared form. I'm guessing I've put this together wrong (I know just enough vba to be very dangerous, but I'm not always comfortable with what I'm doing).
I'm using Access 2007.
Please help?
Laura
I'm using Access 2007.
Code:
Private Sub TCRequestDte_GotFocus()
If Forms![frmTDMEntry].appt_date = "n/a" And Forms![frmTDMEntry].cancel_date = "n/a" Then GoTo err_form_clear
If Forms![frmTDMEntry].cancel_date = "n/a" And Forms![frmTDMEntry].appt_date > Now() Then GoTo err_form_clear
err_form_clear:
MsgBox "Form entry not allowed. This workup is still active." & Chr(13) & "Alert the SC that this form must be resubmitted when the workup is complete." & Chr(13) & "Your form will be reset.", vbInformation, "Invalid Form"
Dim Ctl As Control
On Error Resume Next
For Each Ctl In Me.Controls
Ctl.Value = Null
Next Ctl
RID.SetFocus
End Sub
Please help?
Laura