would like to selected up to three options from an option group

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created an option box and would like to select three of the options
listed in the option box, and can't get it to work, can this be done?

Thanks,
 
When you create an option group, then you bound the group to a field in a
table, and to that field you can enter only one value, so the answer is no.
To get what you asking for, create a border or not, create three option
boxes that are not connected to an option group, and bound each option box to
a different field in the table.
 
Tina Gray said:
I have created an option box and would like to select three of the
options listed in the option box, and can't get it to work, can this
be done?

It's the nature of an option group that it stores only one value, chosen
from among the available options. If you want to choose multiple
options, you'll need to approach this one of two ways:

1. Create a separate field -- probably a yes/no field -- in your table
to represent each option and whether it has been chosen or not. Bind an
independent control on the form to each of these fields. If you want to
impose a restriction that at most three options can be chosen, write
code in various control events and in the form's Before Update event to
enforce the restriction.

Or:

2. Store options in a separate related table, creating one record in
this table for each option chosen. Each record in that table would have
a field for the key of the main record to which it applies, and a field
indicating the option type. A subform on the main form would be the
easiest way to maintain this table, though there are other, more
code-intensive ways of doing it. This is the most flexible way of
storing the option information, but may be more than you need.
 
Dirk,
If I could slip this note in here...
A few days ago (in an old post) we discussed using the "filter" for a
form as the filter for a report...
Doug Steele, you, and I, thought it would fly...
Well, it does... and it really works great!

In the past I've done all sorts of convoluted parameter queries, built
complicated criteria forms, or used complicated "argument" strings in the
OpenReport function... all trying to build report "flexibility". What a
pain!
Here's the code I use... couldn't be simpler...

Private Sub Report_Open(Cancel As Integer)
If Forms!frmCustomers.FilterOn = False Then
Me.Filter = "CustID = Forms!frmCustomers!CustID"
Me.FilterOn = True
Else
Me.Filter = Forms!frmCustomers.Filter
Me.FilterOn = True
End If
End Sub

When the user is looking at all the records, the report only prints the
one record being displayed.
If the user filters the form recordset (ex. by City returning 100
records), the report prints those in a "batch"

Thanks for the help,
Al Camp
 
Al Camp said:
Dirk,
If I could slip this note in here...
A few days ago (in an old post) we discussed using the "filter"
for a form as the filter for a report...
Doug Steele, you, and I, thought it would fly...
Well, it does... and it really works great!

In the past I've done all sorts of convoluted parameter queries,
built complicated criteria forms, or used complicated "argument"
strings in the OpenReport function... all trying to build report
"flexibility". What a pain!
Here's the code I use... couldn't be simpler...

Private Sub Report_Open(Cancel As Integer)
If Forms!frmCustomers.FilterOn = False Then
Me.Filter = "CustID = Forms!frmCustomers!CustID"
Me.FilterOn = True
Else
Me.Filter = Forms!frmCustomers.Filter
Me.FilterOn = True
End If
End Sub

When the user is looking at all the records, the report only
prints the one record being displayed.
If the user filters the form recordset (ex. by City returning 100
records), the report prints those in a "batch"

Yes, that's a great solution under the right circumstances. It doesn't
work when the form is filtered on a lookup value, though. For example,
if the form is bound to a table that stores, say, a numeric EmployeeID,
but has a combo box that displays the employee's name. If the form is
filtered on the name, as displayed in the combo box, Access generates a
hidden query for the filter, and joins it to the form's recordsource to
allow the filter to work. The form's Filter property will then refer to
a field in the hidden query, not in the recordsource of the form -- or
the report. So when you copy this filter to the report's Filter
property, it won't work -- you'll get a parameter prompt for the field.

If your form's filter is not based on any lookup values, though, your
method is just the ticket.
 
Back
Top