Form with variable subforms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I would like to know if this is possible and if so how do you code it. (VBasic is rusty).

For background this program is for my insurance office. I have a form titled "Policy Master" and on that form is a field titled "LineOfBusiness". This field is a combo box linked to a table of possible values. The Policy Master has general information that is common to all types of insurance policies. What I would like is to creat a series of subforms that have the technical details of each different type of policy (such as health insurance vs. car insurance). I would like the current subform to pop up based on the selection in LineofBusiness. I am currently using a series (24) command buttons to get the technical details in. Would it be possible to use something like a if.then.else statement to bring up the correct subform automatically. And if it is what would be the syntax?

Thanks

Scott
 
You can use a tab control (but, I would only suggest a tab control for about
5 or maybe 10 max).


The simply solutions is to use a subform. Remember, a sub-form is not
actually a form, but is just like any regular control on the screen.

Controls do NOT as a rule have to have the same data source as their name.
You can also change/stuff in the field name, or in the case of a sub-form,
the actual form name that the control will use.

So, make your combo box based on a table, and one of the columns can be the
form name.

In the combo box after update, simply pluck out the form name to load..and
set the sub-form control to show whatever form you want.


The combo box after update could be:

me.MySubFormControl.SourceObject = me.MyCbo

The above assumes that the first column of the combo box is the form name
(but, likely is hidden).
 
It sounds like you want to change the SourceObject property of your
subform control on the fly. Sure, this is doable.

Forms!MyFormName!MySubformControlname.SourceObject =
"AnotherSubformName"

Hope this helps,

Peter De Baets
Peter's Software - MS Access Tools for Developers
http://www.peterssoftware.com


Scott said:
Hi,

I would like to know if this is possible and if so how do you code it. (VBasic is rusty).

For background this program is for my insurance office. I have a
form titled "Policy Master" and on that form is a field titled
"LineOfBusiness". This field is a combo box linked to a table of
possible values. The Policy Master has general information that is
common to all types of insurance policies. What I would like is to
creat a series of subforms that have the technical details of each
different type of policy (such as health insurance vs. car insurance).
I would like the current subform to pop up based on the selection in
LineofBusiness. I am currently using a series (24) command buttons to
get the technical details in. Would it be possible to use something
like a if.then.else statement to bring up the correct subform
automatically. And if it is what would be the syntax?
 
Hi Scott,
I'm not a real Guru but I have a similar situation in my
db and here is what I did-
I have a combo box on my form with a list of categories.
Depending upon which category is selected, the user is
moved to a subform for that category to fill out more
information. These are not popup forms as you have so
you would have to replace the DoCmd.GoToControl with
DoCmd.OpenForm, but I think that using case statements
will get you what you want.
Here is my event proc which is in the AfterUpdate
property of the combo box:

Private Sub Category_AfterUpdate()
Dim strFormName As String

Select Case Me.Category.Value
Case "In-Kind"
strFormName = "DInKind"
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
DoCmd.GoToControl strFormName

Case "Honor Of", "Memory Of"
strFormName = "DHonorMemory"
DoCmd.GoToControl strFormName

End Select
strFormName = ""
End Sub

At least maybe this will get you started,
Sandra
-----Original Message-----
Hi,

I would like to know if this is possible and if so how
do you code it. (VBasic is rusty).
For background this program is for my insurance office.
I have a form titled "Policy Master" and on that form is
a field titled "LineOfBusiness". This field is a combo
box linked to a table of possible values. The Policy
Master has general information that is common to all
types of insurance policies. What I would like is to
creat a series of subforms that have the technical
details of each different type of policy (such as health
insurance vs. car insurance). I would like the current
subform to pop up based on the selection in
LineofBusiness. I am currently using a series (24)
command buttons to get the technical details in. Would
it be possible to use something like a if.then.else
statement to bring up the correct subform automatically.
And if it is what would be the syntax?
 
Back
Top