Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Posts
    17

    Unanswered: Handling the OnClick event from a Class module using WithEvents

    For some reason I can't capture the OnClick event from a class module seperate to a form, but I can capture the MouseDown event in Access 97. Has anybody else had this problem and know of a cure?

    My class module [MyClass] code looks like:

    -----------------------------------------------
    Public WithEvents CmdControl As CommandButton

    Private Sub Class_Terminate()
    Set CmdControl = Nothing
    End Sub

    Public Sub SetControl(ByRef aCmd As CommandButton)
    Set CmdControl = aCmd

    'Alternate the two below to capture the different events
    CmdControl.OnClick = "[Event Procedure]"
    'CmdControl.OnMouseDown = "[Event Procedure]"
    End Sub

    Private Sub CmdControl_OnClick()
    MsgBox "Command Clicked!"
    End Sub

    Private Sub CmdControl_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    MsgBox "Command Mouse down!"
    End Sub
    -----------------------------------------------

    And the code in my form [MyForm] looks like:

    -----------------------------------------------
    Private TheClass As MyClass

    Private Sub Form_Open(Cancel As Integer)
    Set TheClass = New MyClass

    TheClass.SetControl Me.Command1
    End Sub

    Private Sub Form_Close()
    Set TheClass = Nothing
    End Sub
    -----------------------------------------------

    Thanks in advance for any help,
    Stephen.

  2. #2
    Join Date
    May 2004
    Posts
    17
    Has anybody had any experience in holding class modules in a seperate library database file. Can you handle events from a form loaded in another database?

    Also, is there anyway to refer to a form from a referenced database for use as a subform? I have a main form in the library database and want to use a subform from the main database but can't find any syntax to specify which database the form resides in.

    Thanks,
    Stephen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •