dannydanny
IS-IT--Management
Hi,
I have about 5 forms which have code that is about 90% identical to each other. (Code to hide textboxes, save a record, delete a record etc.) I would like to create a separate class module to centralize this code so any changes I make, I only have to make to the class module and I don`t have to go through all 5 forms to make the change.
However, I don`t know how to pass objects, like textboxes and references to forms, to the class module.
As a test I tried this:
In my forms:
Dim module as MyModule 'declared at the top
private form_open()
Set module = New MyModule
private sub HideTextBoxButton_Click()
Call module.HideTextBox(txtBox2)
end sub
In MyModule class:
public sub HideTextBox(txt as TextBox)
txt.visible = false
end sub
I always get a runtime error "Object is required" when I try to pass txtBox2 to the instance of MyModule (this line: Call module.HideTextBox(txtBox2))
Am I going about this the right way, or am I on the wrong track?
Thanks for any help,
Danny
I have about 5 forms which have code that is about 90% identical to each other. (Code to hide textboxes, save a record, delete a record etc.) I would like to create a separate class module to centralize this code so any changes I make, I only have to make to the class module and I don`t have to go through all 5 forms to make the change.
However, I don`t know how to pass objects, like textboxes and references to forms, to the class module.
As a test I tried this:
In my forms:
Dim module as MyModule 'declared at the top
private form_open()
Set module = New MyModule
private sub HideTextBoxButton_Click()
Call module.HideTextBox(txtBox2)
end sub
In MyModule class:
public sub HideTextBox(txt as TextBox)
txt.visible = false
end sub
I always get a runtime error "Object is required" when I try to pass txtBox2 to the instance of MyModule (this line: Call module.HideTextBox(txtBox2))
Am I going about this the right way, or am I on the wrong track?
Thanks for any help,
Danny