Interactive Fields in Form

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

Guest

I have a few forms, one master and a few subforms. The master form contains
data that all users will enter, while the subforms are for specific groups.
I would like to have a drop-down menu in the master form where the user
selects what group they're from and have the subform fields appear in the
master form. I'm not very proficient in VBA coding, I was wondering what the
simplest way would be to create this or if there are any sample code or
templates? Thanks!
 
Let's say you have the following: MainForm, SubForm1, SubForm2, SubForm3, etc.


Initially, add SubForm1 to MainForm to get the form/subform format set to
your liking. Change the name of the subform control so that you don't
confuse it with the name of the subform itself (e.g. call it "SubFormAll").
In MainForm, create a combobox with the options SubForm1, SubForm2, etc.
Using the combobox's AfterUpdate event, change the source object for the
subform control:

Me.SubFormAll.SourceObject = Me.ComboBox
Me.SubFormAll.LinkChildFields = [SubFormField]
Me.SubFormAll.LinkMasterFields = [MainFormField]

You can implement this in a menu bar too so that you don't need to create a
combobox or other control in your main form.
 
Thanks for the reply... I don't think I completely understand what you're
saying though. Ok, so now I have 3 subforms (SubForm1, SubForm2, SubForm3).
I would like to have a combobox that has these three as the options, and when
I click on SubForm1 it should open up inside of MainForm.

My questions are:

How do I put SubForm1, SubForm2, SubForm3 in the combobox? Do I just create
a table with their names and point to that? (which is what I'm doing now)

But I don't know how to link it to the actual subform, what do I do to make
SubForm1 open up inside of MainForm when I choose it from the combobox?

Any help is greatly appreciated.

kingston via AccessMonster.com said:
Let's say you have the following: MainForm, SubForm1, SubForm2, SubForm3, etc.


Initially, add SubForm1 to MainForm to get the form/subform format set to
your liking. Change the name of the subform control so that you don't
confuse it with the name of the subform itself (e.g. call it "SubFormAll").
In MainForm, create a combobox with the options SubForm1, SubForm2, etc.
Using the combobox's AfterUpdate event, change the source object for the
subform control:

Me.SubFormAll.SourceObject = Me.ComboBox
Me.SubFormAll.LinkChildFields = [SubFormField]
Me.SubFormAll.LinkMasterFields = [MainFormField]

You can implement this in a menu bar too so that you don't need to create a
combobox or other control in your main form.
I have a few forms, one master and a few subforms. The master form contains
data that all users will enter, while the subforms are for specific groups.
I would like to have a drop-down menu in the master form where the user
selects what group they're from and have the subform fields appear in the
master form. I'm not very proficient in VBA coding, I was wondering what the
simplest way would be to create this or if there are any sample code or
templates? Thanks!
 
Thanks for the reply... I don't think I completely understand what you're
saying though. Ok, so now I have 3 subforms (SubForm1, SubForm2, SubForm3).
I would like to have a combobox that has these three as the options, and when
I click on SubForm1 it should open up inside of MainForm.

My questions are:

How do I put SubForm1, SubForm2, SubForm3 in the combobox? Do I just create
a table with their names and point to that? (which is what I'm doing now)

But I don't know how to link it to the actual subform, what do I do to make
SubForm1 open up inside of MainForm when I choose it from the combobox?

Any help is greatly appreciated.

kingston via AccessMonster.com said:
Let's say you have the following: MainForm, SubForm1, SubForm2, SubForm3, etc.


Initially, add SubForm1 to MainForm to get the form/subform format set to
your liking. Change the name of the subform control so that you don't
confuse it with the name of the subform itself (e.g. call it "SubFormAll").
In MainForm, create a combobox with the options SubForm1, SubForm2, etc.
Using the combobox's AfterUpdate event, change the source object for the
subform control:

Me.SubFormAll.SourceObject = Me.ComboBox
Me.SubFormAll.LinkChildFields = [SubFormField]
Me.SubFormAll.LinkMasterFields = [MainFormField]

You can implement this in a menu bar too so that you don't need to create a
combobox or other control in your main form.
I have a few forms, one master and a few subforms. The master form contains
data that all users will enter, while the subforms are for specific groups.
I would like to have a drop-down menu in the master form where the user
selects what group they're from and have the subform fields appear in the
master form. I'm not very proficient in VBA coding, I was wondering what the
simplest way would be to create this or if there are any sample code or
templates? Thanks!
 
When you create the combobox, type in the values that you want (i.e. the
subform names). You can create a table too and point to it if it's easier.
All that does is provide the names of the subforms to the code. Then you use
the combobox's .AfterUpdate event and the code I provided to change the
subform (create a subform control in the main form first). You'll have to
put the real names of the subform control and the subforms but the rest of
the code is the same.
Thanks for the reply... I don't think I completely understand what you're
saying though. Ok, so now I have 3 subforms (SubForm1, SubForm2, SubForm3).
I would like to have a combobox that has these three as the options, and when
I click on SubForm1 it should open up inside of MainForm.

My questions are:

How do I put SubForm1, SubForm2, SubForm3 in the combobox? Do I just create
a table with their names and point to that? (which is what I'm doing now)

But I don't know how to link it to the actual subform, what do I do to make
SubForm1 open up inside of MainForm when I choose it from the combobox?

Any help is greatly appreciated.
Let's say you have the following: MainForm, SubForm1, SubForm2, SubForm3, etc.
[quoted text clipped - 19 lines]
 
Back
Top