Date in Report Header

G

Gary

I am designing a one page report that consists of 2 subreports to display
the data from 2 tables. One of the fields in both tables is time/date, and
all the records have the same date but different times. I would like to
display the date from these fields in a text box in the report header and
not display the date/time field in each record. So far I cannot figure out
how to get the date from one of the records and put it in the text box. It
seems like this should be easy, but this beginner cannot figure it out.
Any help would be appreciated.
Thanks,
Gary
 
E

Evi

Lets say your date field is called MyDate and your subreport is called MySub
In the textbox in your report Header, put
=Format([MySub].[Report].[MyDate],"dd/mm/yy")

dd/mm/yy would give you the format eg 25/12/08 - replace that with the date
format you require.

Be aware that you can only do this in the report header if all the data in
the report is the same for that field. Otherwise, it reads the first record
in the field only.
Evi
 
G

Gary

That is exactly what I want to do.
I entered this statement,
=Format(rsubGiftCertUseReward.Report.Date,"dd/mm/yy")
in the control Source for my text box in the report header, but when I run
the report the text box displays, "#Name?". I know there is a valid date in
that field of each record.
I put brackets around each item, but Access removes the brackets when I
enter in the property of the text box.
Do you know what I'm going wrong?
Thanks,
Gary
Evi said:
Lets say your date field is called MyDate and your subreport is called
MySub
In the textbox in your report Header, put
=Format([MySub].[Report].[MyDate],"dd/mm/yy")

dd/mm/yy would give you the format eg 25/12/08 - replace that with the
date
format you require.

Be aware that you can only do this in the report header if all the data in
the report is the same for that field. Otherwise, it reads the first
record
in the field only.
Evi


Gary said:
I am designing a one page report that consists of 2 subreports to display
the data from 2 tables. One of the fields in both tables is time/date,
and
all the records have the same date but different times. I would like to
display the date from these fields in a text box in the report header and
not display the date/time field in each record. So far I cannot figure
out
how to get the date from one of the records and put it in the text box.
It
seems like this should be easy, but this beginner cannot figure it out.
Any help would be appreciated.
Thanks,
Gary
 
E

Evi

4 things:
1. Check the name of your sub. Getting the name of control wrong is the
usual cause of a Name# error.
It is not always the same as the name of which appears in your database
window, especially if you have re-used a report.
To do this, click on the Properties button and then click on your subreport.
Click on the Other tab in Properties and look next to Name (not next to
Source Object on the Data tab).
2. You have called your field Date. This is a function in Access (if you
type Date in a piece of code, Access will think you are referring to today's
date) and will cause you all sorts of inexplicable problems but will never
tell you that the problem is caused by a name. Switch on all the options
(Tools, Options, General) to Track name AutoCorrect Info and rename your
field. It will be a pain and will necessitate all sorts of tiring checks in
queries and code but will save you future hassle.
3.Try putting the square boxes around the control names as I have done in my
example.
4. check that you have chosen the correct names and spelt them correctly.
You may have your Date field in a text box called txtDate. If yes, then it
is txtDate that needs to be in your expression.
Evi

Gary said:
That is exactly what I want to do.
I entered this statement,
=Format(rsubGiftCertUseReward.Report.Date,"dd/mm/yy")
in the control Source for my text box in the report header, but when I run
the report the text box displays, "#Name?". I know there is a valid date in
that field of each record.
I put brackets around each item, but Access removes the brackets when I
enter in the property of the text box.
Do you know what I'm going wrong?
Thanks,
Gary
Evi said:
Lets say your date field is called MyDate and your subreport is called
MySub
In the textbox in your report Header, put
=Format([MySub].[Report].[MyDate],"dd/mm/yy")

dd/mm/yy would give you the format eg 25/12/08 - replace that with the
date
format you require.

Be aware that you can only do this in the report header if all the data in
the report is the same for that field. Otherwise, it reads the first
record
in the field only.
Evi


Gary said:
I am designing a one page report that consists of 2 subreports to display
the data from 2 tables. One of the fields in both tables is time/date,
and
all the records have the same date but different times. I would like to
display the date from these fields in a text box in the report header and
not display the date/time field in each record. So far I cannot figure
out
how to get the date from one of the records and put it in the text box.
It
seems like this should be easy, but this beginner cannot figure it out.
Any help would be appreciated.
Thanks,
Gary
 
G

Gary

Evi,
The problem was the name of my subreport. Access assigned a default name and
I was using the name from the database window.
Thank you so much. I didn't find this information in my books and I never
would have figured it out myself.
Gary

Evi said:
4 things:
1. Check the name of your sub. Getting the name of control wrong is the
usual cause of a Name# error.
It is not always the same as the name of which appears in your database
window, especially if you have re-used a report.
To do this, click on the Properties button and then click on your
subreport.
Click on the Other tab in Properties and look next to Name (not next to
Source Object on the Data tab).
2. You have called your field Date. This is a function in Access (if you
type Date in a piece of code, Access will think you are referring to
today's
date) and will cause you all sorts of inexplicable problems but will never
tell you that the problem is caused by a name. Switch on all the options
(Tools, Options, General) to Track name AutoCorrect Info and rename your
field. It will be a pain and will necessitate all sorts of tiring checks
in
queries and code but will save you future hassle.
3.Try putting the square boxes around the control names as I have done in
my
example.
4. check that you have chosen the correct names and spelt them correctly.
You may have your Date field in a text box called txtDate. If yes, then
it
is txtDate that needs to be in your expression.
Evi

Gary said:
That is exactly what I want to do.
I entered this statement,
=Format(rsubGiftCertUseReward.Report.Date,"dd/mm/yy")
in the control Source for my text box in the report header, but when I
run
the report the text box displays, "#Name?". I know there is a valid date in
that field of each record.
I put brackets around each item, but Access removes the brackets when I
enter in the property of the text box.
Do you know what I'm going wrong?
Thanks,
Gary
Evi said:
Lets say your date field is called MyDate and your subreport is called
MySub
In the textbox in your report Header, put
=Format([MySub].[Report].[MyDate],"dd/mm/yy")

dd/mm/yy would give you the format eg 25/12/08 - replace that with the
date
format you require.

Be aware that you can only do this in the report header if all the data in
the report is the same for that field. Otherwise, it reads the first
record
in the field only.
Evi


I am designing a one page report that consists of 2 subreports to display
the data from 2 tables. One of the fields in both tables is time/date,
and
all the records have the same date but different times. I would like
to
display the date from these fields in a text box in the report header and
not display the date/time field in each record. So far I cannot figure
out
how to get the date from one of the records and put it in the text
box.
It
seems like this should be easy, but this beginner cannot figure it
out.
Any help would be appreciated.
Thanks,
Gary
 

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