Solved Pass a code to the detail and header of the form through a class module (1 Viewer)

zelarra821

Registered User.
Local time
Today, 23:52
Joined
Jan 14, 2019
Messages
813
In the code to get header and footer, y get a message that says variable hasn't be defined (HasHeader y HasFooter).
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:52
Joined
May 21, 2018
Messages
8,529
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
 

zelarra821

Registered User.
Local time
Today, 23:52
Joined
Jan 14, 2019
Messages
813
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
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:52
Joined
May 21, 2018
Messages
8,529
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.
 

zelarra821

Registered User.
Local time
Today, 23:52
Joined
Jan 14, 2019
Messages
813
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

  • Libros - copia.accdb
    5 MB · Views: 82

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:52
Joined
May 21, 2018
Messages
8,529
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

Top Bottom