PDA

View Full Version : with events in class module



gregl
11-19-2008, 07:54 PM
I am trying to get the mousedown event (on a rectangle) working through a class module (as I have a large, variable number of rectangles to deal with). There are a few examples around that work in excel, but I cannot get it to work in access.


I have come up with the following code, but it simply does not acknowledge the mousedown event.

In a FORM: (with 2 rectangles called Box0, and Box1)
Private boxes() As New Class1
Private Sub Form_Load()
ReDim Preserve boxes(1)
Set boxes(0).RectGroup = Me.Box0
Set boxes(1).RectGroup = Me.Box1
End Sub

In a Class Module called 'Class1'
Public WithEvents RectGroup As Rectangle
Private Sub RectGroup_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsgBox ("you pressed " & RectGroup.Name)
End Sub

Any assistance will be greatly appreciated