pull a field from a table by date range on form

T

terri

i have a form where i need to fill in a combo box using a date range of a
text box.

If the [admitdate] is between "10/01/2007" AND "09/31/2008" then select
distinctrow [DRGtable1].[strdrg],[DRGtable1].[strDRGdescription] from
[DRGtable1] otherwise enter nothing.

I do not do VBA...please show me how to do this in the combo box itself.
i tried the =iif...but it doesn't work.
terri
 
D

Dale Fye

Terri,

If you are ever going to develop a fully functional database application,
then you are eventually going to have to learn VBA. The key is to start out
with small steps, then use groups like this one to expand your skill set.

As I understand it, you want to populate your combo box with the strDrg and
strDRGDescription columns from table DRGtable1, but only if the value in the
[AdmitDate] field of your form is between 10/1/07 and 9/31/08. Are those
dates firm (never going to change), or do you want them to change to 10/1/08
and 9/31/09 as soon as we enter October of 08?

The way I would handle this is to create a query that looks at the
[AdmitDate] field of your form as part of the criteria of the query. Then,
you can set the RowSource of the combo box to that query. The query would
look something like:

SELECT strDRG, strDRGDescription
FROM DRGtable1
WHERE Forms!yourFormName.[AdminDate]
BETWEEN #10/01/2007# AND #9/30/2008#

If you want to make this a little more generic, so that it will do FY 09
when you get to October, you could set it to:

SELECT strDRG, strDRGDescription
FROM DRGtable1
WHERE Forms!yourFormName.[AdminDate]
BETWEEN DateSerial(Year(DateAdd("m", 3, Date()) - 1, 10, 1)
AND DateSerial(Year(DateAdd("m", 3, Date()), 9, 31)

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
T

terri

thanx Dale...i will try this.
and i will learn vba :)
--
terri


Dale Fye said:
Terri,

If you are ever going to develop a fully functional database application,
then you are eventually going to have to learn VBA. The key is to start out
with small steps, then use groups like this one to expand your skill set.

As I understand it, you want to populate your combo box with the strDrg and
strDRGDescription columns from table DRGtable1, but only if the value in the
[AdmitDate] field of your form is between 10/1/07 and 9/31/08. Are those
dates firm (never going to change), or do you want them to change to 10/1/08
and 9/31/09 as soon as we enter October of 08?

The way I would handle this is to create a query that looks at the
[AdmitDate] field of your form as part of the criteria of the query. Then,
you can set the RowSource of the combo box to that query. The query would
look something like:

SELECT strDRG, strDRGDescription
FROM DRGtable1
WHERE Forms!yourFormName.[AdminDate]
BETWEEN #10/01/2007# AND #9/30/2008#

If you want to make this a little more generic, so that it will do FY 09
when you get to October, you could set it to:

SELECT strDRG, strDRGDescription
FROM DRGtable1
WHERE Forms!yourFormName.[AdminDate]
BETWEEN DateSerial(Year(DateAdd("m", 3, Date()) - 1, 10, 1)
AND DateSerial(Year(DateAdd("m", 3, Date()), 9, 31)

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



terri said:
i have a form where i need to fill in a combo box using a date range of a
text box.

If the [admitdate] is between "10/01/2007" AND "09/31/2008" then select
distinctrow [DRGtable1].[strdrg],[DRGtable1].[strDRGdescription] from
[DRGtable1] otherwise enter nothing.

I do not do VBA...please show me how to do this in the combo box itself.
i tried the =iif...but it doesn't work.
terri
 
D

Dale Fye

let me know how it works out. If you have problems, post back.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



terri said:
thanx Dale...i will try this.
and i will learn vba :)
--
terri


Dale Fye said:
Terri,

If you are ever going to develop a fully functional database application,
then you are eventually going to have to learn VBA. The key is to start out
with small steps, then use groups like this one to expand your skill set.

As I understand it, you want to populate your combo box with the strDrg and
strDRGDescription columns from table DRGtable1, but only if the value in the
[AdmitDate] field of your form is between 10/1/07 and 9/31/08. Are those
dates firm (never going to change), or do you want them to change to 10/1/08
and 9/31/09 as soon as we enter October of 08?

The way I would handle this is to create a query that looks at the
[AdmitDate] field of your form as part of the criteria of the query. Then,
you can set the RowSource of the combo box to that query. The query would
look something like:

SELECT strDRG, strDRGDescription
FROM DRGtable1
WHERE Forms!yourFormName.[AdminDate]
BETWEEN #10/01/2007# AND #9/30/2008#

If you want to make this a little more generic, so that it will do FY 09
when you get to October, you could set it to:

SELECT strDRG, strDRGDescription
FROM DRGtable1
WHERE Forms!yourFormName.[AdminDate]
BETWEEN DateSerial(Year(DateAdd("m", 3, Date()) - 1, 10, 1)
AND DateSerial(Year(DateAdd("m", 3, Date()), 9, 31)

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



terri said:
i have a form where i need to fill in a combo box using a date range of a
text box.

If the [admitdate] is between "10/01/2007" AND "09/31/2008" then select
distinctrow [DRGtable1].[strdrg],[DRGtable1].[strDRGdescription] from
[DRGtable1] otherwise enter nothing.

I do not do VBA...please show me how to do this in the combo box itself.
i tried the =iif...but it doesn't work.
terri
 

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