Mile-O
Back once again...
- Local time
- Today, 05:38
- Joined
- Dec 10, 2002
- Messages
- 11,316
Okay, I'm sick of designing forms whereby I have to go through their individual settings and set things like PopUp to True or RecordSelectors to False.
Therefore I want to create a form class that, in the Form_Open event will do all that form me for every form.
So, I've got a class called AppForm.
Now, that doesn't work, and I don't expect it to work because on each form I need to do some work with regards to instantiating the class.
So, on the form's class module
ThisApp is just another class, dealing with database application stuff, like Name, version, etc. Just in case anyone was wondering.
Now, how do we go about assigning the form to the class as the first event triggered for a form is OnOpen, which is what I want to replace with the OnOpen in the AppForm class?
I guess there must be a way by adding all the database's form collection to a collection object at start-up so that the class will work. But I'm stumped.
Therefore I want to create a form class that, in the Form_Open event will do all that form me for every form.
So, I've got a class called AppForm.
Code:
Option Compare Database
Option Explicit
Private Const cstrEventProc As String = "[Event Procedure]"
Private WithEvents frm As Access.Form
Public Property Get Form() As Access.Form
Set Form = frm
End Property ' Form
Public Property Set Form(param_Form As Access.Form)
Set frm = param_Form
frm.OnOpen = cstrEventProc
End Property ' Form
Private Sub frm_Open(Cancel As Integer)
With frm
' some general form attributes
.Caption = ThisApp.Name
.PopUp = True
.AutoCenter = True
.NavigationButtons = False
.ScrollBars = 0
.BorderStyle = 1
.Moveable = True
.ControlBox = False
.MinMaxButtons = False
.RecordSelectors = False
End With
End Sub ' frm_Open
Now, that doesn't work, and I don't expect it to work because on each form I need to do some work with regards to instantiating the class.
So, on the form's class module
Code:
Private ThisForm As New AppForm
Private Sub Form_Open(Cancel As Integer)
End Sub
ThisApp is just another class, dealing with database application stuff, like Name, version, etc. Just in case anyone was wondering.
Now, how do we go about assigning the form to the class as the first event triggered for a form is OnOpen, which is what I want to replace with the OnOpen in the AppForm class?
I guess there must be a way by adding all the database's form collection to a collection object at start-up so that the class will work. But I'm stumped.
