Access 2010 でカレンダーを作成しました。私は今それをいくつか整えており、いくつかのことをコーディングする「よりクリーンな」方法があるかどうか疑問に思っていました.
いくつかの関数があります:
Mousey()
--> カーソルを標準の指ポインター (標準の Access/VBA ライブラリには含まれていません) に変更します。
ClickDay(intClick As Integer)
--> 詳細については、ユーザーがその日に入ることができます
私のカレンダーには 6 つの行があり、各行は 7 日です。毎日、Mousey()
関数_MouseMove
とClickDay()
関数 onを呼び出します_Click()
。
私が今行っていることは、関数_Click()
を呼び出す42 個すべてのイベント プロシージャと、関数を呼び出すための別の 42 個のイベント プロシージャを作成することです。 ClickDay
_MouseMove
Mousey
明らかに、これは 84 の手順 (それぞれ 3 行) であり、これを削減したいと考えています。
ある種のループを使用して、各関数を 1 つの手順に入れる方法を考えられる人はいますか? ここに私の機能があります:
Private Function ClickDay(intClick As Integer)
'Function that is called when one of the number boxes are clicked
Dim intYear As Integer
Dim intMonth As Integer
Dim intDay As Integer
'Get the pieces of the date based on box that is clicked
intYear = lblYear.Caption
intMonth = ChangeToMonth(lblMonth.Caption)
intDay = Me("t" & intClick).Value
'change global variable
gintDate = DateSerial(intYear, intMonth, intDay)
'go to the date clicked
DoCmd.OpenForm ("frmToday")
End Function
と
Public Function Mousey()
Dim hCur As Long
hCur = LoadCursor(0, IDC_HAND)
If (hCur > 0) Then
SetCursor hCur
End If
End Function