Talismanic
Registered User.
- Local time
- Today, 20:43
- Joined
- May 25, 2000
- Messages
- 377
When I print out the code to my main form I get 12 pages. Most of the code is redundant so I want to write it once in a procedure and call it when I need it.
I am not sure if I am mis-understanding the use of modules but here is an example of what I am trying to do. I want to put this code in a module and then call it every time I need it (twice in one form and once in another).
If txtPW = "Y" And Me!Class = "Nor" Then
Dim strMsg As String, strTitle As String
Dim intStyle As Integer, Cancel As Integer
Dim Answer As Variant
strMsg = "This is a prevailing wag job," & vbCrLf & " " & vbCrLf & "You must enter a class."
strTitle = "Entry Error"
intStyle = vbOKCancel + vbInformation
Answer = MsgBox(strMsg, intStyle, strTitle)
If Answer = vbOKCancel Then Cancel = True
DoCmd.GoToControl "class"
Exit Sub
End If
The name of the module is modPWageCheck so I wrote the call like this:
Private Sub Class_AfterUpdate()
Call modPWageCheck
End Sub
Am I on the right track or do I have the use for Mods wrong?
I am not sure if I am mis-understanding the use of modules but here is an example of what I am trying to do. I want to put this code in a module and then call it every time I need it (twice in one form and once in another).
If txtPW = "Y" And Me!Class = "Nor" Then
Dim strMsg As String, strTitle As String
Dim intStyle As Integer, Cancel As Integer
Dim Answer As Variant
strMsg = "This is a prevailing wag job," & vbCrLf & " " & vbCrLf & "You must enter a class."
strTitle = "Entry Error"
intStyle = vbOKCancel + vbInformation
Answer = MsgBox(strMsg, intStyle, strTitle)
If Answer = vbOKCancel Then Cancel = True
DoCmd.GoToControl "class"
Exit Sub
End If
The name of the module is modPWageCheck so I wrote the call like this:
Private Sub Class_AfterUpdate()
Call modPWageCheck
End Sub
Am I on the right track or do I have the use for Mods wrong?