Combo Box feeding a query

B

Bunky

Good Day to All!

I have a form with a combo box on it that is sending dates to a query. The
Combo Box has a source of Distinct dates from a table. The idea is when the
user selects the 1st (most current date) it will use this date throughout all
the queries in the series for the report. This is working fine. Now, I want
to expand this like this: I want the 2nd and the 3rd and the 4th most current
dates as well. I cannot use DateAdd because the dates a not a set number of
days apart. How can I reference the dates not selected? I have limited the
number of dates shown to 4 so regardless what date is chosen, I want the date
chosen and the 3 that preceeds it.

My code to select the current date from the form is
[forms]![UGPRform]![Combo1]

Thank you in advance for your assistance.
 
A

Arvin Meyer [MVP]

You may have some trouble from the combo, because it only can provide a
single value, but you have to other choices:

1. You can manually choose from a multi-select list box
or:
2. Use the same rowsource as the combo in another query with the TOP
predicate as :

SELECT TOP 4 DateField, ID
FROM YourTable
ORDER BY DateField Desc;
 
B

Bunky

Arvin,

If I go for option 2, how can I tell the query to get the 2nd date or later?
Is that possible? In COBOL (Yes, I am a dinosaur), you could access
whatever level of a table you wanted by simply entering the name of the
element and -1 for the first one down or -2 for the second one.

Thanks a bunch for your assistance!

Arvin Meyer said:
You may have some trouble from the combo, because it only can provide a
single value, but you have to other choices:

1. You can manually choose from a multi-select list box
or:
2. Use the same rowsource as the combo in another query with the TOP
predicate as :

SELECT TOP 4 DateField, ID
FROM YourTable
ORDER BY DateField Desc;
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Bunky said:
Good Day to All!

I have a form with a combo box on it that is sending dates to a query.
The
Combo Box has a source of Distinct dates from a table. The idea is when
the
user selects the 1st (most current date) it will use this date throughout
all
the queries in the series for the report. This is working fine. Now, I
want
to expand this like this: I want the 2nd and the 3rd and the 4th most
current
dates as well. I cannot use DateAdd because the dates a not a set number
of
days apart. How can I reference the dates not selected? I have limited
the
number of dates shown to 4 so regardless what date is chosen, I want the
date
chosen and the 3 that preceeds it.

My code to select the current date from the form is
[forms]![UGPRform]![Combo1]

Thank you in advance for your assistance.
 
A

Arvin Meyer [MVP]

COBOL databases, if I can remember back that far <lol> where almost always
hierarchal, not relational. Access is an ISAM (Indexed Sequential Access
Method) database. There is no predetermined order, which is why I had to
create the Order By clause.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Bunky said:
Arvin,

If I go for option 2, how can I tell the query to get the 2nd date or
later?
Is that possible? In COBOL (Yes, I am a dinosaur), you could access
whatever level of a table you wanted by simply entering the name of the
element and -1 for the first one down or -2 for the second one.

Thanks a bunch for your assistance!

Arvin Meyer said:
You may have some trouble from the combo, because it only can provide a
single value, but you have to other choices:

1. You can manually choose from a multi-select list box
or:
2. Use the same rowsource as the combo in another query with the TOP
predicate as :

SELECT TOP 4 DateField, ID
FROM YourTable
ORDER BY DateField Desc;
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Bunky said:
Good Day to All!

I have a form with a combo box on it that is sending dates to a query.
The
Combo Box has a source of Distinct dates from a table. The idea is
when
the
user selects the 1st (most current date) it will use this date
throughout
all
the queries in the series for the report. This is working fine. Now,
I
want
to expand this like this: I want the 2nd and the 3rd and the 4th most
current
dates as well. I cannot use DateAdd because the dates a not a set
number
of
days apart. How can I reference the dates not selected? I have
limited
the
number of dates shown to 4 so regardless what date is chosen, I want
the
date
chosen and the 3 that preceeds it.

My code to select the current date from the form is
[forms]![UGPRform]![Combo1]

Thank you in advance for your assistance.
 
B

Bunky

Oh, you cut me to the quick! <LOL>. I have figured another method that was
so simple I don't know why I did not see it. Create 2 more Combo boxes; each
has a pull down of the dates available and it is up to you to select the
correct on for each Combo box. Just finished it and it works very well
indeed.

Thank you for your assistance and wit(?)!!

Kent

Arvin Meyer said:
COBOL databases, if I can remember back that far <lol> where almost always
hierarchal, not relational. Access is an ISAM (Indexed Sequential Access
Method) database. There is no predetermined order, which is why I had to
create the Order By clause.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Bunky said:
Arvin,

If I go for option 2, how can I tell the query to get the 2nd date or
later?
Is that possible? In COBOL (Yes, I am a dinosaur), you could access
whatever level of a table you wanted by simply entering the name of the
element and -1 for the first one down or -2 for the second one.

Thanks a bunch for your assistance!

Arvin Meyer said:
You may have some trouble from the combo, because it only can provide a
single value, but you have to other choices:

1. You can manually choose from a multi-select list box
or:
2. Use the same rowsource as the combo in another query with the TOP
predicate as :

SELECT TOP 4 DateField, ID
FROM YourTable
ORDER BY DateField Desc;
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Good Day to All!

I have a form with a combo box on it that is sending dates to a query.
The
Combo Box has a source of Distinct dates from a table. The idea is
when
the
user selects the 1st (most current date) it will use this date
throughout
all
the queries in the series for the report. This is working fine. Now,
I
want
to expand this like this: I want the 2nd and the 3rd and the 4th most
current
dates as well. I cannot use DateAdd because the dates a not a set
number
of
days apart. How can I reference the dates not selected? I have
limited
the
number of dates shown to 4 so regardless what date is chosen, I want
the
date
chosen and the 3 that preceeds it.

My code to select the current date from the form is
[forms]![UGPRform]![Combo1]

Thank you in advance for your assistance.
 

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