R
Ripper
I am using the following FANTASTIC code I received from Albert.
In the form's BeforeUpdate event cancel = MyVerify
Private Function MyVerify()
Dim colFields As New Collection
MyVerify = False
colFields.Add "StudentID,Student Name"
colFields.Add "Teacher,Teacher Name"
colFields.Add "Period,Period"
colFields.Add "ReasonID,Reason"
colFields.Add "Location,Location"
colFields.Add "Description,Description"
MyVerify = vFields(colFields)
End Function
Private Function vFields(colFields As Collection) As Boolean
Dim strErrorText As String
Dim strControl As String
Dim i As Integer
For i = 1 To colFields.Count
strControl = Split(colFields(i), ",")(0)
strErrorText = Split(colFields(i), ",")(1)
If IsNull(Me(strControl)) = True Then
MsgBox strErrorText & " is required", vbExclamation, AppName
Me(strControl).SetFocus
vFields = True
Exit Function
End If
Next i
End Function
My problem is when I have the users use the X to close and save the info on
the form, bypassing that ugly docmd.close bug. Access still prompts me if I
want to close the form and not save the record. I do not want that as an
option! How can I eliminate the yes / no save record warning and still use
the code to prompt the user with my custom messages?
In the form's BeforeUpdate event cancel = MyVerify
Private Function MyVerify()
Dim colFields As New Collection
MyVerify = False
colFields.Add "StudentID,Student Name"
colFields.Add "Teacher,Teacher Name"
colFields.Add "Period,Period"
colFields.Add "ReasonID,Reason"
colFields.Add "Location,Location"
colFields.Add "Description,Description"
MyVerify = vFields(colFields)
End Function
Private Function vFields(colFields As Collection) As Boolean
Dim strErrorText As String
Dim strControl As String
Dim i As Integer
For i = 1 To colFields.Count
strControl = Split(colFields(i), ",")(0)
strErrorText = Split(colFields(i), ",")(1)
If IsNull(Me(strControl)) = True Then
MsgBox strErrorText & " is required", vbExclamation, AppName
Me(strControl).SetFocus
vFields = True
Exit Function
End If
Next i
End Function
My problem is when I have the users use the X to close and save the info on
the form, bypassing that ugly docmd.close bug. Access still prompts me if I
want to close the form and not save the record. I do not want that as an
option! How can I eliminate the yes / no save record warning and still use
the code to prompt the user with my custom messages?