G
Guest
I have recently asked this question ?
I have a form which has the following fields, CourseName, courseStartDate,
CourseFinishDate and a subform with the fields ExamName, ExamDate.
I would like to put an after update event procedure on ExamDate to
Restrict entry to greater then coursestartdate and less then
coursefinishdate also with an error message if the ExamDate is outside the
course Start and finish date.
Is this possible
And I received the following help which was really appreciated.
To compare fields, you need to use the BeforeUpdate event of the form,
rather than the AfterUpdate of the text box. That way, it catches the error
and prevents the save even if the user goes back and changes one of the other
text boxes after entering the ExamDate.
This kind of thing:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Me.ExamDate < Me.CourseStartDate) OR _
(Me.ExamDate > Me.CourseFinishDate) Then
Cancel = True
MsgBox "Exam must be during the course." & vbcrlf & _
"Correct the entry, or press <Esc> to undo."
End If
End Sub
I have tried this suggestion but can't seen to get it to work.
This is what I actually have
I have a Form called frmAddExamToDivision this form has 4 fields called
CourseName, DivisionName, StartDate, FinishDate and a Subform called
frmAddExamToDivisionSubform.
The frmAddExamToDivisionSubform has 3 field called ExamName, ExamDate,
InstructorDetails.
I have tried this but no luck
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Me.ExamDate < Me.StartDate) Or _
(Me.ExamDate > Me.FinishDate) Then
Cancel = True
MsgBox "Exam must be during the course." & vbCrLf & _
"Correct the entry, or press <Esc> to undo."
End If
End Sub
I also tried this
Private Sub Form_BeforeUpdate(Cancel As Integer)
If
(Me.Forms.frmAddExamToDivision.frmAddExamtoDivisionSubform.Form.ExamDate
< Me.Forms.frmAddExamToDivision.StartDate) Or _
(Me.Forms.frmAddExamToDivision.frmAddExamtoDivisionSubform.Form.ExamDate
MsgBox "Exam must be during the course." & vbCrLf & _
"Correct the entry, or press <Esc> to undo."
End If
End Sub
And still no luck
Can you please lend some more assistance?
Thank you
Rodney
I have a form which has the following fields, CourseName, courseStartDate,
CourseFinishDate and a subform with the fields ExamName, ExamDate.
I would like to put an after update event procedure on ExamDate to
Restrict entry to greater then coursestartdate and less then
coursefinishdate also with an error message if the ExamDate is outside the
course Start and finish date.
Is this possible
And I received the following help which was really appreciated.
To compare fields, you need to use the BeforeUpdate event of the form,
rather than the AfterUpdate of the text box. That way, it catches the error
and prevents the save even if the user goes back and changes one of the other
text boxes after entering the ExamDate.
This kind of thing:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Me.ExamDate < Me.CourseStartDate) OR _
(Me.ExamDate > Me.CourseFinishDate) Then
Cancel = True
MsgBox "Exam must be during the course." & vbcrlf & _
"Correct the entry, or press <Esc> to undo."
End If
End Sub
I have tried this suggestion but can't seen to get it to work.
This is what I actually have
I have a Form called frmAddExamToDivision this form has 4 fields called
CourseName, DivisionName, StartDate, FinishDate and a Subform called
frmAddExamToDivisionSubform.
The frmAddExamToDivisionSubform has 3 field called ExamName, ExamDate,
InstructorDetails.
I have tried this but no luck
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Me.ExamDate < Me.StartDate) Or _
(Me.ExamDate > Me.FinishDate) Then
Cancel = True
MsgBox "Exam must be during the course." & vbCrLf & _
"Correct the entry, or press <Esc> to undo."
End If
End Sub
I also tried this
Private Sub Form_BeforeUpdate(Cancel As Integer)
If
(Me.Forms.frmAddExamToDivision.frmAddExamtoDivisionSubform.Form.ExamDate
< Me.Forms.frmAddExamToDivision.StartDate) Or _
(Me.Forms.frmAddExamToDivision.frmAddExamtoDivisionSubform.Form.ExamDate
Cancel = TrueMe.Forms.frmAddExamToDivisionFinishDate) Then
MsgBox "Exam must be during the course." & vbCrLf & _
"Correct the entry, or press <Esc> to undo."
End If
End Sub
And still no luck
Can you please lend some more assistance?
Thank you
Rodney