combo box coding

G

Guest

I have a combo box that has three choices: not subscribed, subscibed &
unsubscibed. I want to have, when this data is changed, the update of a
yes/no field that is hiden based on the combo box choice: subscibed would be
updated to Yes and the other two to NO. I am doing this approach so that the
status is displayed on a sub form as a Yes/No without the problems of using
Yes/No for three possible entires!

I am guessing that whatever code I need would go in the upon change property
of the combo box but since I not messing in the heavy access stuff now days
(I'm a commercial photographer) I need help.

Ken
 
G

Guest

You could use the after update event of the combo box to code an If...Then
statement like;

If me.combobox = "suscribed" then

me.yes/nofield = true

else

me.yes/nofield = false

end if

You'll need to modify the field names to fit your form. Also, if your combo
box contains more than one column in it's row source, and you need to
reference something other than the bound column, you'll need to use the
column property (me.combobox.column(1), etc.)


HTH
 
G

Guest

An easier way would be to use IIF statement from the combo box field for the
check box Control Source.
=IIF([Forms]![YourForm]![YourComboBox] = "subscibed", -1, 0)
 
B

Bob Quintal

=?Utf-8?B?S2VuIEdlaGxl?= <[email protected]>
wrote in
I have a combo box that has three choices: not subscribed,
subscibed & unsubscibed. I want to have, when this data is
changed, the update of a yes/no field that is hiden based on
the combo box choice: subscibed would be updated to Yes and
the other two to NO. I am doing this approach so that the
status is displayed on a sub form as a Yes/No without the
problems of using Yes/No for three possible entires!

I am guessing that whatever code I need would go in the upon
change property of the combo box but since I not messing in
the heavy access stuff now days (I'm a commercial
photographer) I need help.

Ken

What you are trying to do in the subform is imitate an option
group. Imitation is the sincerest form of flattery, so why not
use the real thing?

And yes, option groups can use checkboxes, although radio
buttons would follow the MS design standards better.

What you'd do to use this, setup an index column for your
combobox, give them the numbers 1,"Not
subscribed",2,"subscribed",3, "unsubscribed".
Bind that numeric value to a field in your table. set the
default to 1.
In the subform, use the wizard to create the option group.
Bind it to the numeric field created above.

All done, no code.
 
G

Guest

OK, here is the code I tried based on the field names but I get an error:

= If «Expr» [e-mail] = "1" then
«Expr» [EMAIL-Subscribe] = true
else
«Expr» [EMAIL-Subscribe] = false
end If

The error message is:

"You have entered an operand without an operator"

Probably a basic thing that I am not getting but I just don't mess with the
code writing anymore.

Thanks,

Ken
 
G

Guest

Karl,

Can you expand on this some?

I am trying to get the data in the combo box (not subscibed equaling 2,
subscribed equaling 1 & unscribed equaling 0) to update a Yes/No field called
"EMAIL_subscibed" to "yes" for 1 and "no" for anything else so that the "Yes"
will show on a subform of another form.

I'm not sure how to use your suggestion

Ken

KARL DEWEY said:
An easier way would be to use IIF statement from the combo box field for the
check box Control Source.
=IIF([Forms]![YourForm]![YourComboBox] = "subscibed", -1, 0)
--
KARL DEWEY
Build a little - Test a little


Ken Gehle said:
I have a combo box that has three choices: not subscribed, subscibed &
unsubscibed. I want to have, when this data is changed, the update of a
yes/no field that is hiden based on the combo box choice: subscibed would be
updated to Yes and the other two to NO. I am doing this approach so that the
status is displayed on a sub form as a Yes/No without the problems of using
Yes/No for three possible entires!

I am guessing that whatever code I need would go in the upon change property
of the combo box but since I not messing in the heavy access stuff now days
(I'm a commercial photographer) I need help.

Ken
 
G

Guest

You do know that the form with the combo box will have to be open?

In the Control Source for Checkbox EMAIL_subscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 1, -1, 0)

In the Control Source for Checkbox EMAIL_NOT_subscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 2, -1, 0)

In the Control Source for Checkbox EMAIL_Unsubscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 0, -1, 0)


--
KARL DEWEY
Build a little - Test a little


Ken Gehle said:
Karl,

Can you expand on this some?

I am trying to get the data in the combo box (not subscibed equaling 2,
subscribed equaling 1 & unscribed equaling 0) to update a Yes/No field called
"EMAIL_subscibed" to "yes" for 1 and "no" for anything else so that the "Yes"
will show on a subform of another form.

I'm not sure how to use your suggestion

Ken

KARL DEWEY said:
An easier way would be to use IIF statement from the combo box field for the
check box Control Source.
=IIF([Forms]![YourForm]![YourComboBox] = "subscibed", -1, 0)
--
KARL DEWEY
Build a little - Test a little


Ken Gehle said:
I have a combo box that has three choices: not subscribed, subscibed &
unsubscibed. I want to have, when this data is changed, the update of a
yes/no field that is hiden based on the combo box choice: subscibed would be
updated to Yes and the other two to NO. I am doing this approach so that the
status is displayed on a sub form as a Yes/No without the problems of using
Yes/No for three possible entires!

I am guessing that whatever code I need would go in the upon change property
of the combo box but since I not messing in the heavy access stuff now days
(I'm a commercial photographer) I need help.

Ken
 
G

Guest

KARL DEWEY said:
You do know that the form with the combo box will have to be open?

Yes! And it is.
In the Control Source for Checkbox EMAIL_subscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 1, -1, 0)

In the Control Source for Checkbox EMAIL_NOT_subscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 2, -1, 0)

In the Control Source for Checkbox EMAIL_Unsubscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 0, -1, 0)

I have only to data fields:

a combo box that is called that accepts either 0, 1 or 2 as an entry
via a lablel (not subscribed, subscribed, unsubscribed)

And

a Yes/No formated field called [EMAIL_subscribed]

So ia want the [EMAIL_Subscribed] (a Yes/No) to be updated when the [email]
(0, 1 or 2) data is changed.

All this will allow a subform on another form to display the Yes/No instead
of 0, 1 or 2.

Ken
 
G

Guest

I thought you had three, so just use the first one.
--
KARL DEWEY
Build a little - Test a little


Ken Gehle said:
KARL DEWEY said:
You do know that the form with the combo box will have to be open?

Yes! And it is.
In the Control Source for Checkbox EMAIL_subscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 1, -1, 0)

In the Control Source for Checkbox EMAIL_NOT_subscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 2, -1, 0)

In the Control Source for Checkbox EMAIL_Unsubscibed put this ---
=IIF([Forms]![YourForm]![YourComboBox] = 0, -1, 0)

I have only to data fields:

a combo box that is called that accepts either 0, 1 or 2 as an entry
via a lablel (not subscribed, subscribed, unsubscribed)

And

a Yes/No formated field called [EMAIL_subscribed]

So ia want the [EMAIL_Subscribed] (a Yes/No) to be updated when the [email]
(0, 1 or 2) data is changed.

All this will allow a subform on another form to display the Yes/No instead
of 0, 1 or 2.

Ken[/QUOTE]
 
G

Guest

Bob,

I see what you are saying and what I am doing in the firrst part is the same
result. What I want to happen is that once I update the "e-mail" field then a
hiden field called" emial-subscribed" will get updated to Yes if the answer
is 1, No if it is 0 or 2. This field is then used in a sub form on another
form to show it as Yes or No.

To back up the form where the data is changed for e-mail is called "Client"
and the form where the Yes/No display happens is a subform on Companies, with
that subform showing all who are at that particular company. I just need a
code going to update the "email-subscribed: field when I change the "e-mail"
field.

To further give history, we used to use just a Yes/No for this and it work
just fine but there was a need to add a thrid choice and change it to a combo
selection, thus the problem came into being.

Thank you everyone so far for the suggestions.

Ken
 
B

Bob Quintal

=?Utf-8?B?S2VuIEdlaGxl?= <[email protected]>
wrote in
Bob,

I see what you are saying and what I am doing in the firrst
part is the same result. What I want to happen is that once I
update the "e-mail" field then a hiden field called"
emial-subscribed" will get updated to Yes if the answer is 1,
No if it is 0 or 2. This field is then used in a sub form on
another form to show it as Yes or No.

To back up the form where the data is changed for e-mail is
called "Client" and the form where the Yes/No display happens
is a subform on Companies, with that subform showing all who
are at that particular company. I just need a code going to
update the "email-subscribed: field when I change the "e-mail"
field.

To further give history, we used to use just a Yes/No for this
and it work just fine but there was a need to add a thrid
choice and change it to a combo selection, thus the problem
came into being.

Thank you everyone so far for the suggestions.

Ok, so rather when you needed changing the one field from two
possible states, yes,or no, to one that could hold 3 values, you
created two additional two-state fields.

Anyways, I'd put the 1,2,3 into the combobox as a hidden column,
and create an AfterUpdate event that contains the following code

'*************Begin Code***********
Select case me.cboSubscription
case 1
me!subformControl.form!chkNotSubScribed = true
me!subformControl.form!ChkSubscribed = false
me!subformControl.form!chkunsubscribed = false
case 2
me!subformControl.form!chkNotSubScribed = false
me!subformControl.form!ChkSubscribed = true
me!subformControl.form!chkunsubscribed = false
case 3
me!subformControl.form!chkNotSubScribed = false
me!subformControl.form!ChkSubscribed = false
me!subformControl.form!chkunsubscribed = true

end select
'*************end Code******************

where subformControl should be changed to the control that holds
the subform.
Ken

Bob Quintal said:
=?Utf-8?B?S2VuIEdlaGxl?= <[email protected]>
wrote in


What you are trying to do in the subform is imitate an option
group. Imitation is the sincerest form of flattery, so why
not use the real thing?

And yes, option groups can use checkboxes, although radio
buttons would follow the MS design standards better.

What you'd do to use this, setup an index column for your
combobox, give them the numbers 1,"Not
subscribed",2,"subscribed",3, "unsubscribed".
Bind that numeric value to a field in your table. set the
default to 1.
In the subform, use the wizard to create the option group.
Bind it to the numeric field created above.

All done, no code.
 
G

Guest

OK this is what worked on the After Update property:

Private Sub email_AfterUpdate()
If = 1 Then
[subscribed] = True
Else
[subscribed] = False
End If
End Sub

Thanks for the clues Beetle!

Ken
 

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

Similar Threads


Top