A
A Dubey
I am in the process of converting a very large app
(Access XP/2002) with close to 100 forms and sub forms to
have dynamically configured forms.
By this I mean changing control properties depending on
which customer group is selected.
I have already figured out how to do this by using a
table with all of the controls for each form the
appropriate properties etc.
I have written a routine that will open a form in design
view and append my table with all of the pertinate info.
My problem is it will only work if I call it using the
actual form name or Me.
ie: Call BuildForm(Forms!form1)
or Call BuildForm(Me)
Here is some sample code:
'*********************************************************
************************
Public Sub GetForms()
On Error GoTo Err_GetForms
Dim frmStr As Variant
Dim frm As Form
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
frmStr = obj.name
set frm = frmStr ' This line produces error
Call BuildForm(frm) ' Will Work if
' Set frm = Me (Called from
the actual form -- Not an Option)
' Set frm = Forms!form1 (Where
Form1 is the actual form name)
' I have tried every syntax I
can think of, but can't get it to work.
Next obj
Exit_GetForms:
Exit Sub
Err_GetForms:
MsgBox Err.Description
Resume 'Exit_GetForms
End Sub
'*********************************************************
************************
Public Sub BuildForm(frm As Form)
DoCmd.OpenForm frm, acDesign
'do stuff ( This part of the routine works if I
call in one of these ways.
' Call Buildform(Me)
' Call Buildform(Forms!Form1)
'I cannot seem to get a varible to pass as a Form.
DoCmd.Close acForm, frm.Name, acSaveNo
End Sub
'*********************************************************
************************
(Access XP/2002) with close to 100 forms and sub forms to
have dynamically configured forms.
By this I mean changing control properties depending on
which customer group is selected.
I have already figured out how to do this by using a
table with all of the controls for each form the
appropriate properties etc.
I have written a routine that will open a form in design
view and append my table with all of the pertinate info.
My problem is it will only work if I call it using the
actual form name or Me.
ie: Call BuildForm(Forms!form1)
or Call BuildForm(Me)
Here is some sample code:
'*********************************************************
************************
Public Sub GetForms()
On Error GoTo Err_GetForms
Dim frmStr As Variant
Dim frm As Form
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
frmStr = obj.name
set frm = frmStr ' This line produces error
Call BuildForm(frm) ' Will Work if
' Set frm = Me (Called from
the actual form -- Not an Option)
' Set frm = Forms!form1 (Where
Form1 is the actual form name)
' I have tried every syntax I
can think of, but can't get it to work.
Next obj
Exit_GetForms:
Exit Sub
Err_GetForms:
MsgBox Err.Description
Resume 'Exit_GetForms
End Sub
'*********************************************************
************************
Public Sub BuildForm(frm As Form)
DoCmd.OpenForm frm, acDesign
'do stuff ( This part of the routine works if I
call in one of these ways.
' Call Buildform(Me)
' Call Buildform(Forms!Form1)
'I cannot seem to get a varible to pass as a Form.
DoCmd.Close acForm, frm.Name, acSaveNo
End Sub
'*********************************************************
************************