Assuming that all 30 sections use the same form and table, and that the only
difference is the section ID (which I'll assume is a single field called
SectionID in the table, and that it's numeric), then all you need to do is
put a combo box on the form that changes the data to reflect the section.
1) Put an unbound combo box at the top of the form. Presumably you have a
list of sections in a lookup table. Use that lookup table for the rowsource,
giving the combo box one, two or more columns from the table. Just make sure
that the SectionID field from the lookup table is the bound column in the
combo (you can hid this column if you wish). (Note that if you don't want
the users to select their section from a list, but just want them to type a
section number into a text box, that would be fine too. Just put an unbound
text box at the top of the form.)
2) In the AfterUpdate event of the combo box (or text box), place the
following code:
Me.Recordsource = "Select * From MyTable Where SectionID=" & Me.cboSectionID
Where cboSectionID is the name of the combo box (or text box); MyTable is
the name of the table that the form is based on (not the lookup table); and
SectionID is the field in the table that refers to the section Note that you
can modify the above SQL as you wish, such as to add sorting or whatever.
3) In the BeforeInsert event of the form, add the following:
Me!SectionID = Me.cboSectionID
This will populate the SectionID field of table with the current section ID
when the user creates a record.
Note: Don't make the mistake of binding the combo box to the section ID
field. If you do that, then, when users change the value of the combo box,
they'll be changing the current record. Leave the combo box unbound, and use
the BeforeInsert event to populate the SectionID field.
Note also that you might want to store the current SectionID in a
module-level variable, so that you can use that instead of referring to the
cboSectionID value. If you want to do that, then just declare a module-level
variable, at the top of the form's code module, and just assign it the value
of cboSectionID in the cboSectionID AfterUpdate event.
And that should do it.
Neil
<be*****@gmail.comwrote in message
news:11********************@q69g2000hsb.googlegrou ps.com...
>I have 30 sections in my office, i have a database with a form for
each section. How do i create a form that will let them choose their
section from a pull down and open their form based on their section
selection.