use the value of option group in select query

G

Guest

Hello,

I read through some of the messages here and got lost. I current have a form
that pulls up data from a table based on a select query. I would like to add
on option group so the user can choose to view records with the status of
"open" or "closed" based on the currently selected option button.

I can't figure out how to write the sql statement to translate the default
value of the option group ( 1 or 2 ) in order to use that in the query to
find the status of open or closed and then return that to the select query so
it shows only the records "requested".

I thought this would work:

SELECT Issuestable.[Staff ID], Issuestable.Date, Issuestable.Status,
Issuestable.Note
FROM Issuestable
WHERE

(IF form![open issues for all staff].open = "1"
then Issuestable.Status="open"
Else
Issuestable.Status="closed"
ENDIF);

Kelly
 
T

tina

if you use query criteria, you need to requery the form when an option in
the option group is selected - and perhaps set a default option group value
as well. it might be easier to use the option group to set a filter on the
form, as

If Me!open = 1 Then
Me!Filter = "Status = 'open'"
Me!FilterOn = True
Else
Me!Filter = "Status = 'closed'"
Me!FilterOn = True
End If

put the above code in the option group control's AfterUpdate event
procedure. when the form opens, all records pulled by the query will be
included. once you choose an option from the option group, the records are
filtered to "open" or "closed". you can create a third option, if desired,
to remove the filter entirely (as, Me!FilterOn = False) and show all records
again.

hth
 

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