Select query from Option Group

  • Thread starter Thread starter Curt
  • Start date Start date
C

Curt

I have an unbound listbox that has a qry as the record
source. I also have an optiongroup with 2 buttons (FName
and LName). Is it possible to select a button from the
group and have the qry sorted by that button and requery
the listbox? Or do I need to make 2 querys and have the
record source unbound and bind it from the selection? Any
suggestions would be helpful.

Thanks in advance.
 
I think you are referring to the Row Source property of the list box. I
would set the Row Source property to a SQL statement in the After Update
event of the Option Group.
Dim strOrderBy as String
If Me.grpLastFirst = 1 Then 'first name
strOrderBy= " FName, LName"
Else
strOrderBy = " LName, FName"
End If
Me.lboEmployees.RowSource = "SELECT LName, FName " & _
"FROM tblEmployees ORDER BY " & strOrderBy
 
Thanks, Duane but that does not seem to help. I am using
a query that is using a couple different tables. Also, I
want the listbox to requery if the option buttons are not
used. I only want the option group to be used if the user
chooses to use them. Besides I have other items on the
form and subform that causes the listbox to requery if
certain items are changed. Any other suggestions? thanks
for your help.
 
Is there a reason then why you could use my suggested code with sql like:
Me.lboEmployee.RowSource = "Select * from qryYourQuery ORDER BY " &
strOrderBy
 
Sorry about that Duane you are right I just had it set up
wrong. It works like I requested.

Thanks again, hopefully I will be where you are today by
reading all these newsgroups and trying out different
situations.
 
Back
Top