473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Alternate to switchbox

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.

Jun 15 '07 #1
2 1692
be*****@gmail.com wrote:
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.
Are all 30 forms basically the same? You should be able to make 1 form
and modify it for the particular section but not enough info to
understand your requirements.

One possibly solution:

Create a sub-form on your form and change the SubForm control's
..SourceObject to point to the form to put in the SubForm control space
on the form.

Use the combo box's AfterUpdate event to change the form.

You'll probably need code in the main Form's OnCurrent event to set the
initial form in the Sub Form control.

--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------
Jun 15 '07 #2
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.

Jun 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Toby A Inkster | last post by:
www.authoring.stylesheets] For ages I have provided links to alternate stylesheets from my pages as per W3C recommendations: <link rel="stylesheet" href="baz" type="text/css" title="Baz"...
5
by: User | last post by:
If I want to provide alternate stylesheets (eg red.css, green.css), is it better to put all the stuff that is common to both sheets in a separate css file (eg basic.css) and use @import at the top...
1
by: Carl Draus | last post by:
I was reading the FixPackReadme.txt file in preparation for installing v8.1 Alternate FP7. The prerequisites section says that all DB2 processes must be stopped and doesn't differentiate between...
0
by: Jean-Marc Blaise | last post by:
Hi, From version 8.1.2 one can install alternate fixpacks on Unix/Linux. What is the IBM policy on alternate fixpack; is it for temporary testing or can it be permanent in Production ? If I...
4
by: Mark A | last post by:
Trying to upgrade alternate FP9 to alternate FP9a on Red Hat Linux. After running the following command: ../installAltFixPak -y it says it was successful, but no new directory is created in...
1
by: jeffgeorge | last post by:
Using a bit of code to produce alternate line shading in a report. Seems it should work for a form as well but no luck. Does anyone have any ideas what I need to change or if it is even possible...
1
by: Eric Lindsay | last post by:
I am trying to understand the differences between and uses of persistent, default and alternate styles. I have read http://www.w3.org/TR/REC-html40/present/styles.html section 14.3.2 on...
5
by: Michael R | last post by:
Searching the net I've found a simple technique to add row numbers and alternate colors (for the even and the uneven row) to a continuous form. 1st step: Create a textbox, send it to background...
9
by: johkar | last post by:
I need some browser implementation clarification. In the below example, the alternate stylesheet could be invoked by user agents that support alternate stylesheets or by script. Are there any...
0
by: zgh1970 | last post by:
Hi, All, I have some question on the alternate server for the DB connection on db2 connect server. There is one db2 connection to one host database on the server with the following cfg: ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.