Mouse Events on Controls

358 Views Asked by At

In Access 2010, I built a calendar. I'm sprucing it up some now and was wondering if there was a "cleaner" way of coding a couple things.

I have a couple of functions:
Mousey() --> Changes the cursor to your standard finger pointer (which isn't included in the standard Access/VBA library).

ClickDay(intClick As Integer) --> Allows user to go into that day for more details

On my calendar, I have 6 rows, with 7 days on each row. Each day calls the Mousey() function _MouseMove and the ClickDay() function on _Click().

What I'm doing right now is creating an Event Procedure for all 42 _Click() that calls my ClickDay function and ANOTHER 42 Event Procedures for _MouseMove that calls my Mousey function.

Obviously, that's 84 procedures (at 3 lines each) that I'd like to slim down.

Can anyone think of a way to Put each function in one procedure with a loop of some sort? Here are my functions:

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

and

Public Function Mousey()
    Dim hCur As Long

    hCur = LoadCursor(0, IDC_HAND)
    If (hCur > 0) Then
        SetCursor hCur
    End If
End Function
0

There are 0 best solutions below