Entering value in report control

G

Guest

I am building an Employee database that will print a mailing label report
with labels showing the employee name and a line showing the "Week Ending"
date, which needs to be changed every week. I would like to have a box pop up
in which to enter the date, which would enter that date in every label. I am
having a problem setting this up.

I built the Mailing Label report with the name field from the query. I went
to design view, added a label control with "Week Ending:", and an unbound
text box next to it to hold the date value. I then wrote the following code
in a standard module:

Public Function EndingDate()
Dim StrInput as String, strMsg as String
strMsg = "Enter the date that this time card will end."
strInput = InputBox(strMsg, "Week Ending Date")
EndingDate = strInput
End Function

I set the Control Source property of the unbound text box equal to the
EndingDate function. I then set the OnOpen property of the report to the
EndingDate function so that, when the report opens, the Input Box would open
to accept the value for the date. This seems to be causing an endless loop,
because the Input Box won't close after the value is entered. The only way to
close it is by using Ctrl-Alt-Del which also closes the database. Is my
problem coming from setting the Control Source property of the text box to
the EndingDate function? If so, what should the Control Source be set to in
order to get the value from the EndingDate function? Or is there an easier
way to accomplish this task without using code? Thanks for your help.
 
D

Duane Hookom

You might be able to add a text box to your report and set the control
source to:
=[Enter the date that this time card will end]
 
G

Guest

There's an easier way to get your week ending date into your report. Open
your report's record source query in design view. Select Query and then
Paramerters from the Access menu. A query parameters dialog box will appear.
In the field labeled Parameter enter [Week Ending]. In the Date type field
enter Date/Time. Click OK and save your query. In the control source field
of your Date Ending control on your report enter [Date Ending]. Now,
whenever you run the report you will be prompted for the date ending
information which will appear in your report, hopefully, as you desired.
Good luck.

Ken
 
G

Guest

Duane,

Thanks for your response. Your suggestion works fine but I also need data
validation to ensure that only valid date values can be entered.

Duane Hookom said:
You might be able to add a text box to your report and set the control
source to:
=[Enter the date that this time card will end]

--
Duane Hookom
MS Access MVP


ehunter said:
I am building an Employee database that will print a mailing label report
with labels showing the employee name and a line showing the "Week Ending"
date, which needs to be changed every week. I would like to have a box pop
up
in which to enter the date, which would enter that date in every label. I
am
having a problem setting this up.

I built the Mailing Label report with the name field from the query. I
went
to design view, added a label control with "Week Ending:", and an unbound
text box next to it to hold the date value. I then wrote the following
code
in a standard module:

Public Function EndingDate()
Dim StrInput as String, strMsg as String
strMsg = "Enter the date that this time card will end."
strInput = InputBox(strMsg, "Week Ending Date")
EndingDate = strInput
End Function

I set the Control Source property of the unbound text box equal to the
EndingDate function. I then set the OnOpen property of the report to the
EndingDate function so that, when the report opens, the Input Box would
open
to accept the value for the date. This seems to be causing an endless
loop,
because the Input Box won't close after the value is entered. The only way
to
close it is by using Ctrl-Alt-Del which also closes the database. Is my
problem coming from setting the Control Source property of the text box to
the EndingDate function? If so, what should the Control Source be set to
in
order to get the value from the EndingDate function? Or is there an easier
way to accomplish this task without using code? Thanks for your help.
 
G

Guest

Ken,

Your suggestion gives me the desired result. I get the input box needed, and
the data validation required. Thanks much.

Ken Warthen said:
There's an easier way to get your week ending date into your report. Open
your report's record source query in design view. Select Query and then
Paramerters from the Access menu. A query parameters dialog box will appear.
In the field labeled Parameter enter [Week Ending]. In the Date type field
enter Date/Time. Click OK and save your query. In the control source field
of your Date Ending control on your report enter [Date Ending]. Now,
whenever you run the report you will be prompted for the date ending
information which will appear in your report, hopefully, as you desired.
Good luck.

Ken

ehunter said:
I am building an Employee database that will print a mailing label report
with labels showing the employee name and a line showing the "Week Ending"
date, which needs to be changed every week. I would like to have a box pop up
in which to enter the date, which would enter that date in every label. I am
having a problem setting this up.

I built the Mailing Label report with the name field from the query. I went
to design view, added a label control with "Week Ending:", and an unbound
text box next to it to hold the date value. I then wrote the following code
in a standard module:

Public Function EndingDate()
Dim StrInput as String, strMsg as String
strMsg = "Enter the date that this time card will end."
strInput = InputBox(strMsg, "Week Ending Date")
EndingDate = strInput
End Function

I set the Control Source property of the unbound text box equal to the
EndingDate function. I then set the OnOpen property of the report to the
EndingDate function so that, when the report opens, the Input Box would open
to accept the value for the date. This seems to be causing an endless loop,
because the Input Box won't close after the value is entered. The only way to
close it is by using Ctrl-Alt-Del which also closes the database. Is my
problem coming from setting the Control Source property of the text box to
the EndingDate function? If so, what should the Control Source be set to in
order to get the value from the EndingDate function? Or is there an easier
way to accomplish this task without using code? Thanks for your help.
 

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