Unbound text box as label

L

lars

I have an application form that is used from year to year for the same
agencies.
I want to create a label that displays the year the form is used. I have an
unbound text box and I want to write code that will look at the date field
on the form and bring back a label for the year.

I think the code is something like this:

Dim strFund

If [Application Date] > 1/1/2001 and < 12/31/2001 then strFund = "2001"
else if [Applicaiton Date] > 1/1/2002 and < 12/31/2002 then strFund= "2002"

I am not a programmer, please excuse any gross errors. Can you please help
me? Thanks much!!!
LAR-S
 
B

Bish

You can display a value of a textbox control that is bound
to a date field several ways.

By far the simplest is in the properies window of the form
enter YYYY in the format property. This will do the job
for you.

You can also format the control with Format([Application
Date],"YYYY") either in the format property of in your
code.

The 3rd way is: Year([Application Date]) which will also
have the same result.

The last 2 can also be applied to the Recourd Source if
the source is a query.

Bish...
 
L

lars

Thanks for your answers.

In the case of a fiscal year where the actual dates cross from one year into
another, I would need the formula. Example being July 1, 2002 through June
30, 2003.

Joan Wild said:
Just set the control source of the textbox to
=Year([Application Date])

--
Joan Wild
Microsoft Access MVP

lars said:
I have an application form that is used from year to year for the same
agencies.
I want to create a label that displays the year the form is used. I
have
an
unbound text box and I want to write code that will look at the date field
on the form and bring back a label for the year.

I think the code is something like this:

Dim strFund

If [Application Date] > 1/1/2001 and < 12/31/2001 then strFund = "2001"
else if [Applicaiton Date] > 1/1/2002 and < 12/31/2002 then strFund= "2002"

I am not a programmer, please excuse any gross errors. Can you please help
me? Thanks much!!!
LAR-S
 

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