I agree.
But you can still try to make many procedures as genric as possible and put
them in Modules.
=======================================================
e.g.
This is one way to use a general block of code and place it behind multiple
controls.
It changes the date based on the key pressed while the control has the
focus.
=======================================================
In the OnKeyPress event of a Date field on a form I have this:
Call ChangeDate(KeyAscii, Me![UpdateDate])
=======================================================
I have this code in a standard module:
=======================================================
Public Sub ChangeDate(KeyAscii As Integer, ctl As Control)
On Error GoTo Err_ChangeDate
Const KEY_PLUS = 43, KEY_EQUALS = 61
Const KEY_MINUS = 45, KEY_UNDERSCORE = 95
Const KEY_UM = 77, KEY_LM = 109
Const KEY_UW = 87, KEY_LW = 119
Const KEY_UY = 89, KEY_LY = 121
Const KEY_UT = 84, KEY_LT = 116
Dim Msg As String
Select Case KeyAscii
Case KEY_EQUALS, KEY_PLUS
ctl = DateAdd("d", 1, ctl)
KeyAscii = 0
Case KEY_MINUS, KEY_UNDERSCORE
ctl = DateAdd("d", -1, ctl)
KeyAscii = 0
Case KEY_UT
ctl = DateAdd("d", 10, ctl)
KeyAscii = 0
Case KEY_LT
ctl = DateAdd("d", -10, ctl)
KeyAscii = 0
Case KEY_UW
ctl = DateAdd("ww", 1, ctl)
KeyAscii = 0
Case KEY_LW
ctl = DateAdd("ww", -1, ctl)
KeyAscii = 0
Case KEY_UY
ctl = DateAdd("yyyy", 1, ctl)
KeyAscii = 0
Case KEY_LY
ctl = DateAdd("yyyy", -1, ctl)
KeyAscii = 0
Case KEY_UM
ctl = DateAdd("m", 1, ctl)
KeyAscii = 0
Case KEY_LM
ctl = DateAdd("m", -1, ctl)
KeyAscii = 0
End Select
Exit_ChangeDate:
Exit Sub
Err_ChangeDate:
MsgBox ("Error # " & Str(Err.Number) & " was generated by " & Err.Source
& Chr(13) & Err.Description)
Resume Exit_ChangeDate
End Sub