By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 775 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

TAB CONTROL to load a FORM

P: n/a
I'm starting a new project. A Personnel System. I have considered
opening a single bound form to the main employee table. The user can
scroll the records to any individual. I would like to have a tab
control at the top of the form which would allow the user to select
(PERSONAL), (TRAINING),(DISIPLINARY),and (SICKLEAVE) Tabs. Each Tab
should open a FORM and display the relavant TABLE of records tied to
the Employee being viewed in the MainForm.

How do I get the Tab selected to load a (Form or SubForm Control) and
it's Table?
Can I, or should I close the Form/Table when leaving the selected Tab?

OR ... Should I just open multiple tables at startup, and make the
relevant fields available
in each Tab Page ?
ThankYou
Greg

Dec 10 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
<Ap******@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
I'm starting a new project. A Personnel System. I have considered
opening a single bound form to the main employee table. The user can
scroll the records to any individual. I would like to have a tab
control at the top of the form which would allow the user to select
(PERSONAL), (TRAINING),(DISIPLINARY),and (SICKLEAVE) Tabs. Each Tab
should open a FORM and display the relavant TABLE of records tied to
the Employee being viewed in the MainForm.

How do I get the Tab selected to load a (Form or SubForm Control) and
it's Table?
Can I, or should I close the Form/Table when leaving the selected Tab?

OR ... Should I just open multiple tables at startup, and make the
relevant fields available
in each Tab Page ?
Tabs don't have their own tables. What you would do is create subforms for each
of those tables and place a subform onto each tab page. The standard mechanism
for a subform (MasterLink and ChildLink properties) is what will cause you to
see the records that are related to the main record.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Dec 10 '06 #2

P: n/a
well, you couldn't do it with a tab control, but you could use an option
group, with each button opening a separate form bound to one of the
"subordinate" tables - Personal, Training, Disciplinary, Sick Leave. you can
use a WHERE clause in the OpenForm action to filter the subordinate records
to match the current record in the main form.

you might want to consider keeping everything on one main form, though,
rather than opening separate "pop up" forms. consider the following setup:
create an unbound main form; i'll call it frmMain.
add a tab control with two tab pages in it.
add a subform control to each tab page; on page 1, i'll call the subform
control ChildEmployees, on page2, i'll call the subform control
ChildDetails.
add an unbound textbox control to the main form; i'll call it txtPK, and set
its' Visible property to No.
add an option group with five toggle buttons in it, to the main form; i'll
call it grpChoice.
set the first button's OptionValue property to 0, and its' Caption property
to Employees; set the second button's OptionValue property to 1, and its'
Caption property to Personal; set the third button's OptionValue to 2, and
its' Caption property to Training, and so on for the last two buttons.
set the option group's BorderStyle property to Transparent, and delete the
label attached to the option group control.

now create a new form, bound to tblEmployees, and set its' DefaultView to
ContinuousForms or Datasheet. i'll call the primary key field of
tblEmployees, EmpID.
i'll call the form frmEmployees.

create a new form for each of the subordinate tables - Personal, Training,
Disciplinary, Sick Leave.
each of the subordinate tables should already have a foreign key field in
it, that links it back to tblEmployees. i'll call those foreign keys
personal_EmpID, training_EmpID, disciplinary_EmpID, sickleave_EmpID.
i'll call the forms frmPersonal, frmTraining, frmDisciplinary, frmSickLeave.

okay, now we're ready to connect the dots:
open frmMain in design view.
on tab page1, select ChildEmployees, and set it's SourceObject property to
frmEmployees.
select txtPK, and set its' ControlSource property to

=[ChildEmployees].[Form]![EmpID]

on tab page2, select ChildDetails, and set its' LinkMasterFields property to
txtPK. select grpChoices, and create an event procedure on the Click event.
add the following code to the event procedure, as

Select Case Me!grpChoices
Case 1
Me!ChildDetails.SourceObject = "frmPersonal"
Me!ChildDetails.LinkChildFields = "personal_EmpID"
Case 2
Me!ChildDetails.SourceObject = "frmTraining"
Me!ChildDetails.LinkChildFields = "training_EmpID"
Case 3
Me!ChildDetails.SourceObject = "frmDisciplinary"
Me!ChildDetails.LinkChildFields = "disciplinary_EmpID"
Case 4
Me!ChildDetails.SourceObject = "frmSickLeave"
Me!ChildDetails.LinkChildFields = "sickleave_EmpID"
End Select

If Me!grpChoices = 0 Then
Me!TabCtl0 = 0
Else
Me!TabCtl0 = 1
End If

last but not least, set the tab control's BackStyle property to Transparent,
and Style property to None.

here's how it works. when you open frmMain, you see the employees subform
and the option group of toggle buttons. scroll down to whatever employee you
want to see details about, and click one of the four toggle buttons -
Personal, Training, etc. the employees subform "disappears" and the details
subform appears showing the records related to the employee you chose. click
another button and the subform changes to the newly selected detail
records - still for the same employee. to go back to the employee list,
click the Employees toggle button.

the advantage to this setup is that when frmMain opens, only one subform
loads - frmEmployees. this is quicker than loading five subforms. since the
user can only look at one subform at a time, there's no point in actually
having four additional subforms, one for each subordinate table. instead,
the subform control on the second tab page displays whichever subform is
loaded when a toggle button in the option group is clicked.

hth
<Ap******@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
I'm starting a new project. A Personnel System. I have considered
opening a single bound form to the main employee table. The user can
scroll the records to any individual. I would like to have a tab
control at the top of the form which would allow the user to select
(PERSONAL), (TRAINING),(DISIPLINARY),and (SICKLEAVE) Tabs. Each Tab
should open a FORM and display the relavant TABLE of records tied to
the Employee being viewed in the MainForm.

How do I get the Tab selected to load a (Form or SubForm Control) and
it's Table?
Can I, or should I close the Form/Table when leaving the selected Tab?

OR ... Should I just open multiple tables at startup, and make the
relevant fields available
in each Tab Page ?
ThankYou
Greg

Dec 10 '06 #3

P: n/a

Thankyou all for the great suggestions. I will test run a few and see
what works best for me. I have the added consideration of
(New/Edit/Del) buttons
that I want at the MainForm heading, nad some security features I need
to build in
which I should not be too complex. I'll simply enable/disable the tabs
based on user.
The New/Edit/Del issue may be a problem, since I want it in one place
(the heading)
but it has to work with the main form or subforms, whichever has the
focus.

Greg

Dec 11 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.