Solved Pass a code to the detail and header of the form through a class module

In the code to get header and footer, y get a message that says variable hasn't be defined (HasHeader y HasFooter).
 
Those lines are left over from other code.
Delete the line and replace with something like
If err.number <> 2462 then debug.print er.number & " " & err.description
 
I am not able to get the header code to work. Look, this is the code I'm using:

Code:
Public Sub InitalizeMouseWheel(Fname As Form, Optional TheTextBox As Access.TextBox, Optional MRueda As Boolean = True, _
            Optional SCursor As Boolean)
   On Error GoTo errLabel
    Set Form = Fname
    Set mText = TheTextBox
    Set mHeader = GetHeader(Fname)
    Set mDetail = GetDetail(Fname)
    Me.MoverRueda = MRueda
    Me.SituarCursor = SCursor
    mText.OnClick = "[Event Procedure]"
    mText.OnEnter = "[Event Procedure]"
    mText.OnExit = "[Event Procedure]"
    Form.MouseWheel = "[Event Procedure]"
    If Not mHeader Is Nothing Then mHeader.OnClick = "[Event Procedure]"
    If Not mDetail Is Nothing Then mDetail.OnClick = "[Event Procedure]"
    Exit Sub
error_exit:
    Exit Sub
errLabel:
    MsgBox "InitalizeMouseWheel" & Err.Number & " " & Err.Description, vbInformation, NombreBD
End Sub

Code:
Sub mHeader_Click()
   If Me.MoverRueda Then
        Form.ScrollBars = 2
        Form.RibbonName = "Database"
   End If
End Sub

Sub mDetail_Click()
   If Me.MoverRueda Then
        Form.ScrollBars = 2
        Form.RibbonName = "Database"
   End If
End Sub
 
Looks correct as far as I can tell. Can you post the whole class?
Put a msgbox in the mheader_click to verify the event fires in the class.
 
I've pute a MsgBox and it doesn't do anything.

I don't know if I should call the event from the form, as I do with the textboxes.

Here is the database.
 

Attachments

In the class you forgot to add withevents on mDetail and mHeader.
Private WithEvents mHeader As Access.Section
Private WithEvents mDetail As Access.Section
 

Users who are viewing this thread

Back
Top Bottom