Creating a macro for a form

D

DC Bell

I have a database that lists employees by job
classification (e.g. c=clerical, p=professional). The
input screen is divided into two sections. The top
section has the employees demographic information and the
job classification code. The lower half is separated into
tabs according to classification (e.g. one tab for
clericals, another for professionals).

I would like to enter the classification code near the
top of the screen and have the corresponding tab
automatically display. (e.g. If I type in "c" for the
classification, I would like the clerical tab to display
to input additional data.)

Please advise how to create a macro that would perform
this function, so I don't have to select the relevant tab
each time I enter a new employee.

Thank you,
DC Belanger
 
C

Cindy Smith

Try creating an options box on the top where you select
either clerical or professional. The add an event
procedure for after update that contains syntax similar to
to this to display the appropriate objects depending on
the case.


Private Sub "Name of your option box"_AfterUpdate()
Select Case "Name of your option box"

Case 1 ' Clerical
Me!name of 1st object.Visible = True
Me!name of 2nd object.Visible = True
' etc. For everything in the clerical tab to be visible,
and .visible = False for objects that do not apply to this
case.

Case 2 ' Professional
Me!name of 1st object.Visible = False
'etc. for those objects that apply to this case.

I hope this helps, CS
 
S

Steve Schapel

DC,

Each Tab on the tab control has its own name. By default thay are
named PageX. You can use a GoToControl action in a macro to achieve
your purpose. In the scenario you mentioned, you would use 2
GoToControl actions, each with a Condition, as follows...

Condition: [job classification]="c"
Action: GoToControl
ControlName: Page1

Condition: [job classification]="p"
Action: GoToControl
ControlName: Page2

Obviously you need to substitute your own actual field name and Page
numbers.

This macro would go on the After Update event of the job
classification field.

- Steve Schapel, Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top