BrokenBiker
ManicMechanic
- Local time
- Today, 10:04
- Joined
- Mar 22, 2006
- Messages
- 128
Well, many people use the mousetrap database for field validation, but it wasn't quite working for me.
http://www.access-programmers.co.uk/forums/showthread.php?t=38364&highlight=mousetrap
The Assessment form has an OnCurrent event and AfterUpdate events for DLookUp that messes up the BeforeUpdate event in the mousetrap db. This db uses a separate function (Validate) to check the fields. It's called by various commands.
Form Current Sample:
AfterUpdate Sample:
Validate Function:
It's designed to allow you to close an 'empty' or full record, but not a partially filled record. You are prompted to save (--continue filling in info--) or not(--delete the record--). Also, you can't use the navigation buttons to move out of an empty or partially filled record, but you can view 'open' or 'all' assessment w/ the commands (filters) in the upper left corner of the form
Thanks goes out to SamDeMan for helping me along.
http://www.access-programmers.co.uk/forums/showthread.php?t=106218
http://www.access-programmers.co.uk/forums/showthread.php?t=38364&highlight=mousetrap
The Assessment form has an OnCurrent event and AfterUpdate events for DLookUp that messes up the BeforeUpdate event in the mousetrap db. This db uses a separate function (Validate) to check the fields. It's called by various commands.
Form Current Sample:
Code:
Private Sub Form_Current()
Dim TECInfo As String
TECInfo = Nz(DLookup("[MAINTENANCE ACTION]", "[qryShowTECInfo]"), "")
[TECDescription] = TECInfo
Dim TECBaseline As String
TECBaseline = Nz(DLookup("[Baseline]", "[qryShowTECInfo]"), "")
[Baseline] = TECBaseline
End Sub
AfterUpdate Sample:
Code:
Private Sub Inspection_Type_AfterUpdate()
On Error GoTo Err_Inspection_Type_AfterUpdate
If (Forms![Assessment Form]![Inspection Type] = "SI") Then
Forms![Assessment Form]![Main Assessee] = "9999A"
End If
If (Forms![Assessment Form]![Inspection Type] = "UCR") Then
Forms![Assessment Form]![Main Assessee] = "9999B"
Forms![Assessment Form]![TEC] = "802"
Forms![Assessment Form]![Rating] = "Non Rated"
End If
Dim MainAssesseeRank As String
MainAssesseeRank = Nz(DLookup("[Employee RANK]", "[qryShowMainAssesseeInfo]"), "")
[AssesseeRank] = MainAssesseeRank
Dim MainAssesseeName As String
MainAssesseeName = Nz(DLookup("[Employee NAME]", "[qryShowMainAssesseeInfo]"), "")
[AssesseeName] = MainAssesseeName
Dim MainAssesseeAFSC As String
MainAssesseeAFSC = Nz(DLookup("[AFSC]", "[qryShowMainAssesseeInfo]"), "")
[AssesseeAFSC] = MainAssesseeAFSC
Exit_Inspection_Type_AfterUpdate:
Exit Sub
Err_Inspection_Type_AfterUpdate:
MsgBox Err.Description
Resume Exit_Inspection_Type_AfterUpdate
End Sub
Validate Function:
Code:
Function Validate() As Boolean
If IsNull(Me.Rating) Then
'MsgBox removed for testing
Cancel = True
DoCmd.GoToControl "Rating"
Exit Function
Else
End If
'etc for all fields
Validate = True
End Function
It's designed to allow you to close an 'empty' or full record, but not a partially filled record. You are prompted to save (--continue filling in info--) or not(--delete the record--). Also, you can't use the navigation buttons to move out of an empty or partially filled record, but you can view 'open' or 'all' assessment w/ the commands (filters) in the upper left corner of the form
Thanks goes out to SamDeMan for helping me along.
http://www.access-programmers.co.uk/forums/showthread.php?t=106218