Help with options

G

Guest

Hi,

I have an existing database that has a sat checkbox and an unsat checkbox
and a non-participant checkbox. I only want the ability to check off one at
a time. I tried using the option but the data once it is checked can only be
stored in one place. I want the abiltiy to only check on box at a time and
store each field in its appropriate field in the table that it applies to.
Is this possible?

Help.
JudyT
 
M

Matt

Hi,

I have an existing database that has a sat checkbox and an unsat checkbox
and a non-participant checkbox. I only want the ability to check off one at
a time. I tried using the option but the data once it is checked can only be
stored in one place. I want the abiltiy to only check on box at a time and
store each field in its appropriate field in the table that it applies to.
Is this possible?

Help.
JudyT


You can put an "Option Group" on the form, and then place the check
boxes in it. It will only allow you to have one selected at a time.

To do this place the Option Group on the form first and name it
whatever you want to. Then click the check box and hover over the
Option Group (doing this should cause a black shadow to appear in the
Option Group). Once the shadow appears click again. Now the checkbox
is part of the Option Group. Add as many as you need to!

You can hide the border of the option group if you like.

To find out which box is checked you can used optionGroupName.Value in
VBA.
 
G

Guest

Hi Judy

Of course you "could" disable any control on a form if something else
happens and then re-enable it OnCurrent.

But - This seems just the type of work that option groups were made for.

Create the option group
Set the value as 1 2 and 3 - put names on the buttons so users know what
they are.
Use the AfterUpdate event to set value to your controls or fields.


Private Sub FrameName_AfterUpdate()
Select Case Me!FrameName
Case 1
Me.SomeField = Something
Case 2
Me.SomeAnotherField = Something else
Case 3
Me.YetAnotherField = Something else again
End Select
End Sub

Hope this helps
 
S

storrboy

While it makes more sense to use an option group and a single field,
what you want is simple. Add the following to the AfterUpdate events
of each checkbox
Modify the checkbox names as required. The idea is that if the updated
one is not checked (true) then exit the event, otherwise set the other
two to false.

If Not Me!CheckSat Then Exit Sub
Me!CheckUnsat = False
Me!CheckNonParticipant = False
 
G

Guest

If you are going to use the process shown in Storrboy's post (which is fine)
you will need to also add the code to the OnCurrent so you can navigate from
record to record.
 
G

Guest

Wayne,
This works okay but it is not posting back to the table that it is
associated with! Can you tell me how to make it associate with the
table/field it associates with and to save that data?
Thank you,
JudyT
 
G

Guest

well, i am not following you...
you say, "use an option group and a single field" I only know how to make
an option group, label each field and then save it for later use. This gives
me the option for three fields...are you saying do an option group for one
field? and if so, the field does "not" have the after update ability to do
an event. Please explain, I am very new to this function of access. I am
willing to do it this way but need more guidance.
 
S

storrboy

well, i am not following you...
you say, "use an option group and a single field" I only know how to make
an option group, label each field and then save it for later use. This gives
me the option for three fields...

An option group can only be bound to one field, and it can can only
contain one value regardless of how many options there are. Fields are
in tables and queries, not forms. A control can be bound to field -
the option group is the bound control, each option in the group is a
control but are not themselves bound. The selected option gives the
group control a value, thereby updating the table.

Also, this may require you to create another table that contains the
option values and a description if you ever need to represent the
value as text (ie. 1 = Sat, 2 = Unsat....) The option group can only
contain a numerical value (Integer I think), so if you have a reoprt
that shows Sat, then this new table would provide a link betweent the
number and word Sat.

Plan carefully as this change may affect many other things. Read
through the help files and look at the sample db's that ship with
Access for examples. If it is too complicated it may be worth your
while to leave it as 3 fields and programmatically validate them,
keepping option groups in mind for future use.
 
G

Guest

I do believe that this is too complicated and do want to leave it as three
fields but what do you mean by programmatically validate them?
 
S

storrboy

As outlined in previous posts, you'll need to check using code that
only one is selected before a record is updated (BeforeUpdate event),
also while navigating between records (OnCurrent event) you'll need to
make sure the checks reflect what the table has.
 
G

Guest

This is what i have for my vb how does this look to you?
I keep getting a compile error-method or data member not found?
Private Sub Frame126_AfterUpdate()
Select Case Me!FrameName
Case 1
Me.Sat = Sat
Case 2
Me.Unsat = Unsat
Case 3
Me.Non -Participant = Non - Participant
End Select
End Sub
 
S

storrboy

I don't think we're following each other.
Is this now an option group? I was under the impression you were
staying with 3 individual check boxes.

If you are using an option group (the Frame126_Afterupdate event makes
me think so), no code is required. Making a selection will give the
option group a value and allow only one checkbox to be selected.
 
G

Guest

You are correct, I am using the wrong thing. So if i have three check boxes
and only want one at a time to be checked then i would used this:
If Not Me!CheckSat Then Exit Sub
Me!CheckUnsat = False
Me!CheckNonParticipant = False
per your instruction?
Do i put this statement in each of the properties of each checkbox? If so,
i would then change for instance if I were going to change the property in
the unsat box it should look like this
If Not Me!CheckUnsat Then Exit Sub
Me!Checksat = False
Me!CheckNonParticipant = False

I am very so to vb code. pleas give more guidance.
 
S

storrboy

I do believe we're back on track. Yes, that's what you do. The
AfterUpdate event of each would get a likeness of the 3 lines,
modified to change the 'other' checkboxes. The idea is that the first
line says - If this control is false, then don't do anything because I
don't know in this event which they intend to check off. The other two
lines (because if the code gets that far it has determined that the
before mentioned box is True) uncheck the other two boxes. So the
first line should refer to the checkbox that the event belongs to.
Change the other two lines to be the other pair of checkboxes.

If Not Me!CheckUnsat Then Exit Sub
Me!Checksat = False
Me!CheckNonParticipant = False

As Wayne mentioned previously, when you are done, make sure the
behaviour is as expected when you navigate through records. If each
checkbox is bound to a table or query field, then I don't think it
will be an issue, but it's better to test thoroughly to make sure.
 
G

Guest

Okay, I am getting a runtime error 2465-Drill data can't find the field
CheckSat referred in your expression. Should i change the the CheckSat to
just say Sat? or just Unsat or Just nonparticipant? Help!
 
G

Guest

Okay, I am getting syntax error...is it becuase my field title is Individual
Sat? Does the ? question mark make for errors?
 
S

storrboy

The ? can be a problem as it is used in pattern matching. Either
remove it (from the field name, control name, everywhere) or try
enclosing the control name in [ ]

If Not Me![Sat?] Then Exit Sub
Me![UnSat?] = False
Me![NonParticipant] = False

ect.
 

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

timestamp 3
Clear All Checkboxes 1
Requery subform doesn't display all records 1
Help with Date Query 5
make checkbox disappear 2
CheckBox Help 4
Unable to edit data in SQL backend table 2
Limit Drop Down List 4

Top