Sorting A Database Using a Combo Box

S

Steve

Hi all-

Been reading discussions all morning here and haven't quite found what
i'm looking for for my particular situation.

In essence, right now I have a review data option in my interface that
allows users to set a certain date range and list all data for that
date range and by default it currently is sorted by sitename, however
I'd like to also be able to sort by Date/Time and Type.

My plan right now is to use a Combo Box that has all three Options in
it and when you choose one, will sort accordingly.

Here is hopefully the pertinent information someone needs to give me
some ideas and a little better direction:

----
Combo3 Row Source: SELECT slist.slist FROM slist ORDER BY slist.slist;
slist field name: slist
slist data type: text
slist display control: combo box
slist row source type: field list
slist row source: SELECT sortlist.[Site Name], sortlist.ldate,
sortlist.Type FROM sortlist ORDER BY sortlist.[Site Name],
sortlist.ldate, sortlist.Type, sortlist.[Site Name] Or sortlist.ldate
Or sortlist.Type;

sortlist field name: site name type: text
site name row source: SELECT wdata.sitename FROM wdata ORDER BY
wdata.sitename;

sortlist field name: type type: text
type row source: SELECT wdata.Type FROM wdata ORDER BY wdata.Type;

sortlist field name: ldate type: date/time
----

this was something i tried adapting from a similar posting

---
Private Sub Combo3_AfterUpdate()

If Me.Combo3.Value = "Site Name" Then
Me.Child0.RowSource = "Select * From slist Order By [sitename]
"

ElseIf Me.Combo3.Value = "Date/Time" Then
Me.Child0.RowSource = "Select * From slist Order By [ldate] "

Else
Me.Child0.RowSource = "Select * From slist Order By [type] "

End If

End Sub
-----


Child0 is the subform which has the source object as
"Query.dataReviewQ" however there is no option to do a .RowSource.

Hopefully this is enough to give me a hand, if not let me know and I
will gladly reply with information requested.

Thanks in advance,

Steve L.
 
A

Arvin Meyer [MVP]

You can do that, but because of the delineators used for different
datatypes, there will be a little bit of extra work. Use a table or value
list for the combo box's row source, with 2 columns, the first being set to
a zero width and the second the sort criterion description.

Now you can either use a saved query, or a select statement to do the
selection in the combo's AfterUpdate event. I'd use a Case Statement instead
of If ... Then ... Else.

Subforms don't have a .RowSource property. The property that you are looking
for is the .RecordSource property.
 

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