yes no option button

D

dtm

OK since my last request wasnt clear enough for some people let me try this
again.

I have a form where i select a value from a drop down list. This then
populates part of the form.

I have a yes and no option button created with the 'option group'. When this
form loads neither of the option buttons are selected. when i select from
the drop down nothing is selected for the option buttons either.

The option buttons enable or disable a text box depending on if the yes or
no is selected. Enable for Yes, disabled for No.

I have the following code behind the Y/N buttons

If [Frame20] = "1" Then [rma_log.Pendings] = "Yes" Else
[rma_log.Pendings] = "No"
If [Frame20] = "1" Then [PendingNumber].Enabled = True Else
[PendingNumber].Enabled = False

So i write a yes or no to the table and enable or disable the next box.

Here is my problem. when i select from the drop down to prefill the form it
also prefills this enabled or disabled text box (pendingnumber). remember by
default no y/n is selected so the text box is disabled even if it has data
in it.

Fine, i solved this by putting this code behind the "pendingnumber" text
box...
If [PendingNumber] > "0" Then [PendingNumber].Enabled = True Else
[PendingNumber].Enabled = False

Now the problem is i cannot get the yes or no option buttons to select with
code. I want to be able to prefill the form from the dropdown and have the
appropriate yes or no selected. I have tried this code behind the
pendingnumber box but it doesnt work: If [PendingNumber] > "0" Then
[Option23] = "1" Else [option24] = "0"

Can anyone help me out with this?
 
P

PC Datasheet

It looks like you need to use:
If [PendingNumber] > "0" Then
Me!Frame20 = 1
Else
Me!Frame20 = 2
End If


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!
 
G

Guest

Comments inline......

dtm said:
OK since my last request wasnt clear enough for some people let me try this
again.

I have a form where i select a value from a drop down list. This then
populates part of the form.

I have a yes and no option button created with the 'option group'. When this
form loads neither of the option buttons are selected. when i select from


So far, it sounds like you have a bound form and an unbound Option Group on
the form.
the drop down nothing is selected for the option buttons either.

What do you mean by "the drop down"? (Remember, YOU are the only on that can
see the form and controls.)

The option buttons enable or disable a text box depending on if the yes or
no is selected. Enable for Yes, disabled for No.

I have the following code behind the Y/N buttons

If [Frame20] = "1" Then [rma_log.Pendings] = "Yes" Else
[rma_log.Pendings] = "No"
If [Frame20] = "1" Then [PendingNumber].Enabled = True Else
[PendingNumber].Enabled = False


Which event are you using?
Is the code on an event for "Frame20" or on the "option buttons"? (It should
be the Frame).

It looks like you are using the single line IF..THEN construct.
I think a better way (IMHO) to write it is:

If [Frame20] = "1" Then
[rma_log.Pendings] = "Yes"
[PendingNumber].Enabled = True
Else
[rma_log.Pendings] = "No"
[PendingNumber].Enabled = False
End If

So i write a yes or no to the table and enable or disable the next box.

Here is my problem. when i select from the drop down to prefill the form it


Please post the code behind the combo box.

also prefills this enabled or disabled text box (pendingnumber). remember by
default no y/n is selected so the text box is disabled even if it has data
in it.

Fine, i solved this by putting this code behind the "pendingnumber" text
box...
If [PendingNumber] > "0" Then [PendingNumber].Enabled = True Else
[PendingNumber].Enabled = False

So the text box is disabled by default. Then how do you enter a number in
the text box that is disabled, so that the code runs to enable the text
box????.......

Now the problem is i cannot get the yes or no option buttons to select with
code. I want to be able to prefill the form from the dropdown and have the
appropriate yes or no selected. I have tried this code behind the
pendingnumber box but it doesnt work: If [PendingNumber] > "0" Then
[Option23] = "1" Else [option24] = "0"

You have to set the value of the "OPTION FRAME", not the option buttons.

Example:

If [PendingNumber] > "0" Then
[Frame20] = "1"
Else
[Frame20] = "0"
End If


Can anyone help me out with this?


You should start using a naming convention. Is "[PendingNumber]" the name of
the table field or the name of a control on the form?


It's just a matter of explaining the problem in enough detail and such a way
that we can understand. Since we can't see what you have done or know your
level of expertise, sometimes it takes a little longer.

Try calling someone on the phone and explain how to program a VCR to record
a single show next Wed. when you don't know what the remote looks like or
what the screen looks like..... it's very difficult!! :-D
 
S

StopThisAdvertising

PC Datasheet said:
If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.

These 1000 (if at all a real figure..) is only the result of
-- 4 years abusing the newsgroups.
-- 4 years blatantly advertising and job hunting.

You only care about making money, and you act as if the groups are your private hunting ground.
So why would ANYBODY ever trust a person like you and hire you?
********************************************************
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!

Please Steve, do contact a psychiatrist ...

Arno R
 
M

Marshall Barton

dtm said:
OK since my last request wasnt clear enough for some people let me try this
again.

I have a form where i select a value from a drop down list. This then
populates part of the form.

I have a yes and no option button created with the 'option group'. When this
form loads neither of the option buttons are selected. when i select from
the drop down nothing is selected for the option buttons either.

The option buttons enable or disable a text box depending on if the yes or
no is selected. Enable for Yes, disabled for No.

I have the following code behind the Y/N buttons

If [Frame20] = "1" Then [rma_log.Pendings] = "Yes" Else
[rma_log.Pendings] = "No"
If [Frame20] = "1" Then [PendingNumber].Enabled = True Else
[PendingNumber].Enabled = False

So i write a yes or no to the table and enable or disable the next box.

Here is my problem. when i select from the drop down to prefill the form it
also prefills this enabled or disabled text box (pendingnumber). remember by
default no y/n is selected so the text box is disabled even if it has data
in it.

Fine, i solved this by putting this code behind the "pendingnumber" text
box...
If [PendingNumber] > "0" Then [PendingNumber].Enabled = True Else
[PendingNumber].Enabled = False

Now the problem is i cannot get the yes or no option buttons to select with
code. I want to be able to prefill the form from the dropdown and have the
appropriate yes or no selected. I have tried this code behind the
pendingnumber box but it doesnt work: If [PendingNumber] > "0" Then
[Option23] = "1" Else [option24] = "0"


I really did not follow all that, but I do see where you are
using " marks around a lot of numbers. The option group
frame's value is an integer that should not be compared to a
string. This is likely to be true in many other places too.
I am particularly concerned with your use of a string when
assinging a value to PendingNumber.

Also, if your Option23, etc variables are the options within
an option group, then you can not set their value (they
don't have a Value property). Instead you have to assign
the selected option's OptionValue property to the frame's
value property. I'm just guessing that what you want in
this case: Me.Frame20 = 1 to select Option23
 

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