Re: Custom Sort Order - Combo Box
- From: "Larry Linson" <bouncer@xxxxxxxxxxxxx>
- Date: Tue, 06 Jun 2006 05:58:42 GMT
I believe you need to remove the Max function from the OrderBy in the first
Query.
Larry Linson
Microsoft Access MVP
"Matthias Klaey" <mpky@xxxxxxxxxxx> wrote in message
news:1cf9821ttlr7d2jlso8v4sf4dejmqhqt0f@xxxxxxxxxx
"beconrad" <beconrad@xxxxxxxxx> wrote:
Hi all,
I am not sure if what I want to do is possible, and if it is I have not
been able to figure out how to do it. This is what I would like:
1. I have a data entry form with a field called Insurance. That field
uses a combo box which takes its information from query on the
Insurance table. At the moment the drop down list is sorted in
alphabetical order.
2. When a user clicks the drop-down box, I would like the first three
entries they see to represent the three most recently chosen insurance
carriers, i.e. if the last three entries chosen for the table were
carrierA, carrierB and carrieerC, those choices should appear at the
top of the list. The remainder of the table should continue to be in
alphabetical order.
Before I go any furfher I would just like to know if this is even
possible.
Thanks,
Bonnie
I assume that you have some number, say "InsuranceNr", that gives the
order of the most recent entries.
I would use three queries.
The first, called "qry_Top3", returns the mos recent 3 entries:
SELECT TOP 3 tblInsurance.Carrier
FROM tblInsurance
GROUP BY tblInsurance.Carrier
ORDER BY Max(tblInsurance.InsuranceNr) DESC;
The second query, called "qry_Rest", gives the other carriers:
SELECT DISTINCT tblInsurance.Carrier
FROM tblInsurance
LEFT JOIN qry_Top3 ON tblInsurance.Carrier = qry_Top3.Carrier
WHERE qry_Top3.Carrier Is Null
ORDER BY tblInsurance.Carrier;
The third query, used as the record source of he combo box, is the
union of the firs two:
SELEC Carrier FROM qry_Top3
UNION ALL
SELEC Carrier FROM qry_Rest;
Of course, you will have to requery the combo box on the OnCurrent
event.
HTH
Mathias Kläy
--
www.kcc.ch
.
- Follow-Ups:
- Re: Custom Sort Order - Combo Box
- From: Matthias Klaey
- Re: Custom Sort Order - Combo Box
- References:
- Custom Sort Order - Combo Box
- From: beconrad
- Re: Custom Sort Order - Combo Box
- From: Matthias Klaey
- Custom Sort Order - Combo Box
- Prev by Date: Re: Oracle and Access
- Next by Date: vba function within Access query
- Previous by thread: Re: Custom Sort Order - Combo Box
- Next by thread: Re: Custom Sort Order - Combo Box
- Index(es):
Relevant Pages
|
Loading