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

This If/Then Has Got to Be Easy But....

P: n/a
I have a database of employee's names -- if they are on a certain
disciplinary level then a box called CAP is checked in the employee's
name table.

I have a form that has a combo list of employees' names so that
supervisors can check on various past disciplinary actions. There is
nothing on the form except the combo list and a command button.

In order to display the data correctly there are two different macros
that I have -- one if the person is "on CAP" (i.e., CAP = True) and
the other where the person is "not on CAP" (i.e., CAP = False)

The structure I am basically going for is:

If CAP is TRUE then
Run Macro1
If CAP is FALSE then
Run Macro2

I know this is incredibly simple but I am just having terrible trouble
with the syntax in the "On Click" procedure -- Access needs to look at
the record of the employee whose name is in the combo box -- then see
if the employee is (or is not) on CAP, and then run the appropriate
macro.

Please help! I'm a relatively new self-taught user and have been able
to get everything else to work... just not this!

Thanks

Jun 11 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If I got it correctly, you might want to use the following as a
rowsource for the combo:

SELECT EmployeeName, CAP FROM tabNames

(with obvious meanings for EmployeeName, CAP and tabNames)
Then your code should look like

IF cmbCAP.Column(1) THEN
run macro1
ELSE
run macro2
END IF
Jun 11 '07 #2

P: n/a
Add a second column to your combo box. Give it a width of zero.

Then, in the controlsource for the combo box add a second field -- the CAP
field. So the control source should have two fields: the one that's there,
and the CAP field.

Next, in your OnClick event, use the following:

If Me.MyCombo.Column(1) Then
docmd.RunMacro "Macro1"
Else
docmd.RunMacro "Macro2"
End If

Replace "MyCombo" in the above with whatever your combo box is called.

The Column property is zero-based. So Column(1) in the above refers to the
second column of the combo box.

If your combo box already has two columns, then just add a third, and adjust
everything written here accordingly.

HTH,

Neil

"Isaac" <im***@sio.midco.netwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
>I have a database of employee's names -- if they are on a certain
disciplinary level then a box called CAP is checked in the employee's
name table.

I have a form that has a combo list of employees' names so that
supervisors can check on various past disciplinary actions. There is
nothing on the form except the combo list and a command button.

In order to display the data correctly there are two different macros
that I have -- one if the person is "on CAP" (i.e., CAP = True) and
the other where the person is "not on CAP" (i.e., CAP = False)

The structure I am basically going for is:

If CAP is TRUE then
Run Macro1
If CAP is FALSE then
Run Macro2

I know this is incredibly simple but I am just having terrible trouble
with the syntax in the "On Click" procedure -- Access needs to look at
the record of the employee whose name is in the combo box -- then see
if the employee is (or is not) on CAP, and then run the appropriate
macro.

Please help! I'm a relatively new self-taught user and have been able
to get everything else to work... just not this!

Thanks

Jun 11 '07 #3

P: n/a
That did it! Thanks!


Jun 11 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.