A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Copy Cat Ain't Working



 
 
Thread Tools Display Modes
  #11  
Old September 11th, 2005, 04:08 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

Assuming that you copied and pasted the criterion expression exactly as it
is in your query, the problem is that you have two spaces between Report and
Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]



Try this instead:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]


--

Ken Snell
MS ACCESS MVP


"shep" wrote in message
...
It appears the problem lies in the query. I changed the criterion as you
instructed and on entering the start and end dates the report opens
without
the parameter request; however the report does not contain any data.

Here is the criterion I had inserted originally:
=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]


With this I got data in the report, but had the parameter request.

With the original criterion, I opened the form, entered the dates, then
ran
the query and got the parameter request. I did the same thing with
criterion
you provided and the query ran without the parameter request, but did not
pull data from the table.

Here is code for the unbound field on the report.
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "rptReferralsV1"
If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then
Cancel = True
End If
End Sub

Also, on the form I originally had this code:
Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub

After one of the revisions we made, I got an error and debug highlited
this
code. I just deleted and the error msg cleared. Maybe I caused another
problem when I deleted this code.

The complete original form code is futher down in the dialog.

I appreciate the time and effort you have given!

"Ken Snell [MVP]" wrote:

In the query, is the criterion expression that is reading the end date
value
looking like this:
[Forms]![Report Date Range]![End Date]

If not, change it to the above.

If it does, then my first guess is that you've misspelled the form name
or
the control name in the query's criterion expression. However, based on
the
code excerpts that you've posted, that doesn't appear to be the case.

The parameter request could also be coming from the report itself -- a
control on the report may be using the form's control's value in a
control
source? See if you can identify whether it's the query or the report that
is
prompting the parameter window to show -- you can do this if you open the
form itself directly from the database window, enter start and end dates,
and then open the query (the one that the report uses) from the database
window and see if you get the parameter.
--

Ken Snell
MS ACCESS MVP



"shep" wrote in message
...
Yes Sir! That did it. Thanks!

However, I still have something mixed up. I run the report and the
form
pops up. I enter the dates and click Preview and I get a box:
Enter Parameter Value Forms!Report Date Range!End Date and that is a
place to enter date. I enter the End Date and the report runs.

So I suppose I have something wrong in the form code. Here is form
code:

Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub


Private Sub Preview_Click()
If IsNull([Start Date]) Or IsNull([End Date]) Then
MsgBox "You must enter both Start and End dates."
DoCmd.GoToControl "Start Date"
Else
If [Start Date] [End Date] Then
MsgBox "End date must be greater than Start Date."
DoCmd.GoToControl "Start Date"
Else
Me.Visible = False
End If
End If
End Sub
Would you be so kind as to heip me resolve this also? Many thanks

"Ken Snell [MVP]" wrote:

Sorry... it appears that I misread the original code. Try this:

If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then

--

Ken Snell
MS ACCESS MVP

"shep" wrote in message
...
Thanks for your response. I revised per your instruction and it
worked;i.e.,
the form opened and accepted dates, but when I clicked PreviewI got
error
Msg:
Runtime error 2467
The expression you entered refers to an object that is closed or
doesn't
exist

I clicked debug and it highlited the following code line, the one I
modified
If Not CurrentProject.AllReports("Report Date Range").IsLoaded Then

The only advantage I see in this procedure is that if user does not
enter
an
end date that is later than the start date a prompt appears. So
this
is
not
something for which I have dire need. But if you see an easy fix
I'll
try
it.

Thanks again, your response may help others as well.

"Ken Snell [MVP]" wrote:

For ACCESS 2002 and higher version(s), there is an IsLoaded
property
for
CurrentProject.AllReports object... perhaps this is what was meant
to
be
used?

If Not CurrentProject.AllReports("Report Date Range").IsLoaded Then

--

Ken Snell
MS ACCESS MVP


"Brendan Reynolds" wrote in
message
...
There's no build-in function called IsLoaded (AccessObject
objects
have
an
IsLoaded property, but that is not what is being used here). It's
probably
a custom function in a module in the template. To fix the
problem,
find
and import the module, or copy and paste the function into one of
your
own
standard modules.

--
Brendan Reynolds (MVP)

"shep" wrote in message
...
In one of the MS ACCESS templates, the developer created a form
Report
Date
Range for Start and End dates and for the form, a report and its
underlying
query, has code to call the form for entering the date range for
generating
the report. The report has an unbound field for this and there
is
code
in
the criteria of date field on the query. The form also has a
command
button
with code to Preview the report.

I am trying to use what he or she did with not much success so
far.
I
entered the code as is replacing only the name of the report
with
my
own.

Here is code for the unbound field:
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog,
"rptReferralsV1"
If Not IsLoaded("Report Date Range") Then
Cancel = True
End If
End Sub
When I run the report it goes to the code and IsLoaded is
highlighted
with
this error Msg: Compile error Sub or Function not defined.

What is wrong?

Thanks














  #12  
Old September 11th, 2005, 04:16 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

drat.... newsreader put extraneous characters in my post... here is a
corrected version:

Assuming that you copied and pasted the criterion expression exactly as it
is in your query, the problem is that you have two spaces between Report and
Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And

=[forms]![Report Date Range]![End Date]


Try this instead:

=[forms]![Report Date Range]![Start Date] And

=[forms]![Report Date Range]![End Date]

--

Ken Snell
MS ACCESS MVP


"Ken Snell [MVP]" wrote in message
...
Assuming that you copied and pasted the criterion expression exactly as it
is in your query, the problem is that you have two spaces between Report
and Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]



Try this instead:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]


--

Ken Snell
MS ACCESS MVP


"shep" wrote in message
...
It appears the problem lies in the query. I changed the criterion as you
instructed and on entering the start and end dates the report opens
without
the parameter request; however the report does not contain any data.

Here is the criterion I had inserted originally:
=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]


With this I got data in the report, but had the parameter request.

With the original criterion, I opened the form, entered the dates, then
ran
the query and got the parameter request. I did the same thing with
criterion
you provided and the query ran without the parameter request, but did not
pull data from the table.

Here is code for the unbound field on the report.
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "rptReferralsV1"
If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then
Cancel = True
End If
End Sub

Also, on the form I originally had this code:
Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub

After one of the revisions we made, I got an error and debug highlited
this
code. I just deleted and the error msg cleared. Maybe I caused another
problem when I deleted this code.

The complete original form code is futher down in the dialog.

I appreciate the time and effort you have given!

"Ken Snell [MVP]" wrote:

In the query, is the criterion expression that is reading the end date
value
looking like this:
[Forms]![Report Date Range]![End Date]

If not, change it to the above.

If it does, then my first guess is that you've misspelled the form name
or
the control name in the query's criterion expression. However, based on
the
code excerpts that you've posted, that doesn't appear to be the case.

The parameter request could also be coming from the report itself -- a
control on the report may be using the form's control's value in a
control
source? See if you can identify whether it's the query or the report
that is
prompting the parameter window to show -- you can do this if you open
the
form itself directly from the database window, enter start and end
dates,
and then open the query (the one that the report uses) from the database
window and see if you get the parameter.
--

Ken Snell
MS ACCESS MVP



"shep" wrote in message
...
Yes Sir! That did it. Thanks!

However, I still have something mixed up. I run the report and the
form
pops up. I enter the dates and click Preview and I get a box:
Enter Parameter Value Forms!Report Date Range!End Date and that is a
place to enter date. I enter the End Date and the report runs.

So I suppose I have something wrong in the form code. Here is form
code:

Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub


Private Sub Preview_Click()
If IsNull([Start Date]) Or IsNull([End Date]) Then
MsgBox "You must enter both Start and End dates."
DoCmd.GoToControl "Start Date"
Else
If [Start Date] [End Date] Then
MsgBox "End date must be greater than Start Date."
DoCmd.GoToControl "Start Date"
Else
Me.Visible = False
End If
End If
End Sub
Would you be so kind as to heip me resolve this also? Many thanks

"Ken Snell [MVP]" wrote:

Sorry... it appears that I misread the original code. Try this:

If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then

--

Ken Snell
MS ACCESS MVP

"shep" wrote in message
...
Thanks for your response. I revised per your instruction and it
worked;i.e.,
the form opened and accepted dates, but when I clicked PreviewI got
error
Msg:
Runtime error 2467
The expression you entered refers to an object that is closed or
doesn't
exist

I clicked debug and it highlited the following code line, the one I
modified
If Not CurrentProject.AllReports("Report Date Range").IsLoaded Then

The only advantage I see in this procedure is that if user does not
enter
an
end date that is later than the start date a prompt appears. So
this
is
not
something for which I have dire need. But if you see an easy fix
I'll
try
it.

Thanks again, your response may help others as well.

"Ken Snell [MVP]" wrote:

For ACCESS 2002 and higher version(s), there is an IsLoaded
property
for
CurrentProject.AllReports object... perhaps this is what was meant
to
be
used?

If Not CurrentProject.AllReports("Report Date Range").IsLoaded
Then

--

Ken Snell
MS ACCESS MVP


"Brendan Reynolds" wrote in
message
...
There's no build-in function called IsLoaded (AccessObject
objects
have
an
IsLoaded property, but that is not what is being used here).
It's
probably
a custom function in a module in the template. To fix the
problem,
find
and import the module, or copy and paste the function into one
of
your
own
standard modules.

--
Brendan Reynolds (MVP)

"shep" wrote in message
...
In one of the MS ACCESS templates, the developer created a form
Report
Date
Range for Start and End dates and for the form, a report and
its
underlying
query, has code to call the form for entering the date range
for
generating
the report. The report has an unbound field for this and there
is
code
in
the criteria of date field on the query. The form also has a
command
button
with code to Preview the report.

I am trying to use what he or she did with not much success so
far.
I
entered the code as is replacing only the name of the report
with
my
own.

Here is code for the unbound field:
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog,
"rptReferralsV1"
If Not IsLoaded("Report Date Range") Then
Cancel = True
End If
End Sub
When I run the report it goes to the code and IsLoaded is
highlighted
with
this error Msg: Compile error Sub or Function not defined.

What is wrong?

Thanks
















  #13  
Old September 11th, 2005, 02:35 PM
shep
external usenet poster
 
Posts: n/a
Default

Hooray! Even tho I am embarrassed.
It works! I added two popup calendars to make it easy for folks that will
use it.
Thank you again - very much. You are indeed MVP!!

After all you have done for me I am reluctant to ask for more help;
however....
Several people have asked for help the last few months in getting a field on
reports to automatically pull the date range entered. I would like to do
that as well, but have not been able to get any of the responses to work. I
put an unbound field on the report and set control source to:
=[Start Date]&" To "&[End Date]
When I run the report, it asks for start and end dates twice, the 2nd time
to fill the unbound field with date range.
How can I get the date range to fill automatically?

"Ken Snell [MVP]" wrote:

drat.... newsreader put extraneous characters in my post... here is a
corrected version:

Assuming that you copied and pasted the criterion expression exactly as it
is in your query, the problem is that you have two spaces between Report and
Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And

=[forms]![Report Date Range]![End Date]


Try this instead:

=[forms]![Report Date Range]![Start Date] And

=[forms]![Report Date Range]![End Date]

--

Ken Snell
MS ACCESS MVP


"Ken Snell [MVP]" wrote in message
...
Assuming that you copied and pasted the criterion expression exactly as it
is in your query, the problem is that you have two spaces between Report
and Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]



Try this instead:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]


--

Ken Snell
MS ACCESS MVP


"shep" wrote in message
...
It appears the problem lies in the query. I changed the criterion as you
instructed and on entering the start and end dates the report opens
without
the parameter request; however the report does not contain any data.

Here is the criterion I had inserted originally:
=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]

With this I got data in the report, but had the parameter request.

With the original criterion, I opened the form, entered the dates, then
ran
the query and got the parameter request. I did the same thing with
criterion
you provided and the query ran without the parameter request, but did not
pull data from the table.

Here is code for the unbound field on the report.
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "rptReferralsV1"
If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then
Cancel = True
End If
End Sub

Also, on the form I originally had this code:
Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub

After one of the revisions we made, I got an error and debug highlited
this
code. I just deleted and the error msg cleared. Maybe I caused another
problem when I deleted this code.

The complete original form code is futher down in the dialog.

I appreciate the time and effort you have given!

"Ken Snell [MVP]" wrote:

In the query, is the criterion expression that is reading the end date
value
looking like this:
[Forms]![Report Date Range]![End Date]

If not, change it to the above.

If it does, then my first guess is that you've misspelled the form name
or
the control name in the query's criterion expression. However, based on
the
code excerpts that you've posted, that doesn't appear to be the case.

The parameter request could also be coming from the report itself -- a
control on the report may be using the form's control's value in a
control
source? See if you can identify whether it's the query or the report
that is
prompting the parameter window to show -- you can do this if you open
the
form itself directly from the database window, enter start and end
dates,
and then open the query (the one that the report uses) from the database
window and see if you get the parameter.
--

Ken Snell
MS ACCESS MVP



"shep" wrote in message
...
Yes Sir! That did it. Thanks!

However, I still have something mixed up. I run the report and the
form
pops up. I enter the dates and click Preview and I get a box:
Enter Parameter Value Forms!Report Date Range!End Date and that is a
place to enter date. I enter the End Date and the report runs.

So I suppose I have something wrong in the form code. Here is form
code:

Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub


Private Sub Preview_Click()
If IsNull([Start Date]) Or IsNull([End Date]) Then
MsgBox "You must enter both Start and End dates."
DoCmd.GoToControl "Start Date"
Else
If [Start Date] [End Date] Then
MsgBox "End date must be greater than Start Date."
DoCmd.GoToControl "Start Date"
Else
Me.Visible = False
End If
End If
End Sub
Would you be so kind as to heip me resolve this also? Many thanks

"Ken Snell [MVP]" wrote:

Sorry... it appears that I misread the original code. Try this:

If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then

--

Ken Snell
MS ACCESS MVP

"shep" wrote in message
...
Thanks for your response. I revised per your instruction and it
worked;i.e.,
the form opened and accepted dates, but when I clicked PreviewI got
error
Msg:
Runtime error 2467
The expression you entered refers to an object that is closed or
doesn't
exist

I clicked debug and it highlited the following code line, the one I
modified
If Not CurrentProject.AllReports("Report Date Range").IsLoaded Then

The only advantage I see in this procedure is that if user does not
enter
an
end date that is later than the start date a prompt appears. So
this
is
not
something for which I have dire need. But if you see an easy fix
I'll
try
it.

Thanks again, your response may help others as well.

"Ken Snell [MVP]" wrote:

For ACCESS 2002 and higher version(s), there is an IsLoaded
property
for
CurrentProject.AllReports object... perhaps this is what was meant
to
be
used?

If Not CurrentProject.AllReports("Report Date Range").IsLoaded
Then

--

Ken Snell
MS ACCESS MVP


"Brendan Reynolds" wrote in
message
...
There's no build-in function called IsLoaded (AccessObject
objects
have
an
IsLoaded property, but that is not what is being used here).
It's
probably
a custom function in a module in the template. To fix the
problem,
find
and import the module, or copy and paste the function into one
of
your
own
standard modules.

--
Brendan Reynolds (MVP)

"shep" wrote in message
...
In one of the MS ACCESS templates, the developer created a form
Report
Date
Range for Start and End dates and for the form, a report and
its
underlying
query, has code to call the form for entering the date range
for
generating
the report. The report has an unbound field for this and there
is
code
in
the criteria of date field on the query. The form also has a
command
button
with code to Preview the report.

I am trying to use what he or she did with not much success so
far.
I
entered the code as is replacing only the name of the report
with
my
own.

Here is code for the unbound field:
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog,
"rptReferralsV1"
If Not IsLoaded("Report Date Range") Then
Cancel = True
End If
End Sub
When I run the report it goes to the code and IsLoaded is
highlighted
with
this error Msg: Compile error Sub or Function not defined.

What is wrong?

Thanks















  #14  
Old September 12th, 2005, 12:12 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

Assuming that you want to get the dates from the form itself, use a control
source like this for a textbox on the report:

=[forms]![Report Date Range]![Start Date] & " To " & [forms]![Report Date
Range]![End Date]

If you want to specifically format the date in some way (perhaps you want
month spelled out), you can use the Format function:

=Format([forms]![Report Date Range]![Start Date], "mmmm d, yyyy") & " To " &
Format([forms]![Report Date Range]![End Date], "mmmm d, yyyy")
--

Ken Snell
MS ACCESS MVP


"shep" wrote in message
...
Hooray! Even tho I am embarrassed.
It works! I added two popup calendars to make it easy for folks that will
use it.
Thank you again - very much. You are indeed MVP!!

After all you have done for me I am reluctant to ask for more help;
however....
Several people have asked for help the last few months in getting a field
on
reports to automatically pull the date range entered. I would like to do
that as well, but have not been able to get any of the responses to work.
I
put an unbound field on the report and set control source to:
=[Start Date]&" To "&[End Date]
When I run the report, it asks for start and end dates twice, the 2nd time
to fill the unbound field with date range.
How can I get the date range to fill automatically?

"Ken Snell [MVP]" wrote:

drat.... newsreader put extraneous characters in my post... here is a
corrected version:

Assuming that you copied and pasted the criterion expression exactly as
it
is in your query, the problem is that you have two spaces between Report
and
Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And

=[forms]![Report Date Range]![End Date]


Try this instead:

=[forms]![Report Date Range]![Start Date] And

=[forms]![Report Date Range]![End Date]

--

Ken Snell
MS ACCESS MVP


"Ken Snell [MVP]" wrote in message
...
Assuming that you copied and pasted the criterion expression exactly as
it
is in your query, the problem is that you have two spaces between
Report
and Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]


Try this instead:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]

--

Ken Snell
MS ACCESS MVP


"shep" wrote in message
...
It appears the problem lies in the query. I changed the criterion as
you
instructed and on entering the start and end dates the report opens
without
the parameter request; however the report does not contain any data.

Here is the criterion I had inserted originally:
=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]

With this I got data in the report, but had the parameter request.

With the original criterion, I opened the form, entered the dates,
then
ran
the query and got the parameter request. I did the same thing with
criterion
you provided and the query ran without the parameter request, but did
not
pull data from the table.

Here is code for the unbound field on the report.
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "rptReferralsV1"
If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then
Cancel = True
End If
End Sub

Also, on the form I originally had this code:
Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub

After one of the revisions we made, I got an error and debug highlited
this
code. I just deleted and the error msg cleared. Maybe I caused
another
problem when I deleted this code.

The complete original form code is futher down in the dialog.

I appreciate the time and effort you have given!

"Ken Snell [MVP]" wrote:

In the query, is the criterion expression that is reading the end
date
value
looking like this:
[Forms]![Report Date Range]![End Date]

If not, change it to the above.

If it does, then my first guess is that you've misspelled the form
name
or
the control name in the query's criterion expression. However, based
on
the
code excerpts that you've posted, that doesn't appear to be the case.

The parameter request could also be coming from the report itself --
a
control on the report may be using the form's control's value in a
control
source? See if you can identify whether it's the query or the report
that is
prompting the parameter window to show -- you can do this if you open
the
form itself directly from the database window, enter start and end
dates,
and then open the query (the one that the report uses) from the
database
window and see if you get the parameter.
--

Ken Snell
MS ACCESS MVP



"shep" wrote in message
...
Yes Sir! That did it. Thanks!

However, I still have something mixed up. I run the report and the
form
pops up. I enter the dates and click Preview and I get a box:
Enter Parameter Value Forms!Report Date Range!End Date and that
is a
place to enter date. I enter the End Date and the report runs.

So I suppose I have something wrong in the form code. Here is form
code:

Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub


Private Sub Preview_Click()
If IsNull([Start Date]) Or IsNull([End Date]) Then
MsgBox "You must enter both Start and End dates."
DoCmd.GoToControl "Start Date"
Else
If [Start Date] [End Date] Then
MsgBox "End date must be greater than Start Date."
DoCmd.GoToControl "Start Date"
Else
Me.Visible = False
End If
End If
End Sub
Would you be so kind as to heip me resolve this also? Many thanks

"Ken Snell [MVP]" wrote:

Sorry... it appears that I misread the original code. Try this:

If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then

--

Ken Snell
MS ACCESS MVP

"shep" wrote in message
...
Thanks for your response. I revised per your instruction and it
worked;i.e.,
the form opened and accepted dates, but when I clicked PreviewI
got
error
Msg:
Runtime error 2467
The expression you entered refers to an object that is closed or
doesn't
exist

I clicked debug and it highlited the following code line, the
one I
modified
If Not CurrentProject.AllReports("Report Date Range").IsLoaded
Then

The only advantage I see in this procedure is that if user does
not
enter
an
end date that is later than the start date a prompt appears. So
this
is
not
something for which I have dire need. But if you see an easy
fix
I'll
try
it.

Thanks again, your response may help others as well.

"Ken Snell [MVP]" wrote:

For ACCESS 2002 and higher version(s), there is an IsLoaded
property
for
CurrentProject.AllReports object... perhaps this is what was
meant
to
be
used?

If Not CurrentProject.AllReports("Report Date Range").IsLoaded
Then

--

Ken Snell
MS ACCESS MVP


"Brendan Reynolds" wrote
in
message
...
There's no build-in function called IsLoaded (AccessObject
objects
have
an
IsLoaded property, but that is not what is being used here).
It's
probably
a custom function in a module in the template. To fix the
problem,
find
and import the module, or copy and paste the function into
one
of
your
own
standard modules.

--
Brendan Reynolds (MVP)

"shep" wrote in message
...
In one of the MS ACCESS templates, the developer created a
form
Report
Date
Range for Start and End dates and for the form, a report and
its
underlying
query, has code to call the form for entering the date range
for
generating
the report. The report has an unbound field for this and
there
is
code
in
the criteria of date field on the query. The form also has
a
command
button
with code to Preview the report.

I am trying to use what he or she did with not much success
so
far.
I
entered the code as is replacing only the name of the report
with
my
own.

Here is code for the unbound field:
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog,
"rptReferralsV1"
If Not IsLoaded("Report Date Range") Then
Cancel = True
End If
End Sub
When I run the report it goes to the code and IsLoaded is
highlighted
with
this error Msg: Compile error Sub or Function not
defined.

What is wrong?

Thanks

















  #15  
Old September 12th, 2005, 04:13 PM
shep
external usenet poster
 
Posts: n/a
Default

Once more, THANK YOU !!

"Ken Snell [MVP]" wrote:

Assuming that you want to get the dates from the form itself, use a control
source like this for a textbox on the report:

=[forms]![Report Date Range]![Start Date] & " To " & [forms]![Report Date
Range]![End Date]

If you want to specifically format the date in some way (perhaps you want
month spelled out), you can use the Format function:

=Format([forms]![Report Date Range]![Start Date], "mmmm d, yyyy") & " To " &
Format([forms]![Report Date Range]![End Date], "mmmm d, yyyy")
--

Ken Snell
MS ACCESS MVP


"shep" wrote in message
...
Hooray! Even tho I am embarrassed.
It works! I added two popup calendars to make it easy for folks that will
use it.
Thank you again - very much. You are indeed MVP!!

After all you have done for me I am reluctant to ask for more help;
however....
Several people have asked for help the last few months in getting a field
on
reports to automatically pull the date range entered. I would like to do
that as well, but have not been able to get any of the responses to work.
I
put an unbound field on the report and set control source to:
=[Start Date]&" To "&[End Date]
When I run the report, it asks for start and end dates twice, the 2nd time
to fill the unbound field with date range.
How can I get the date range to fill automatically?

"Ken Snell [MVP]" wrote:

drat.... newsreader put extraneous characters in my post... here is a
corrected version:

Assuming that you copied and pasted the criterion expression exactly as
it
is in your query, the problem is that you have two spaces between Report
and
Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And
=[forms]![Report Date Range]![End Date]


Try this instead:

=[forms]![Report Date Range]![Start Date] And
=[forms]![Report Date Range]![End Date]

--

Ken Snell
MS ACCESS MVP


"Ken Snell [MVP]" wrote in message
...
Assuming that you copied and pasted the criterion expression exactly as
it
is in your query, the problem is that you have two spaces between
Report
and Date in the second part of the expression:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]


Try this instead:

=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]

--

Ken Snell
MS ACCESS MVP


"shep" wrote in message
...
It appears the problem lies in the query. I changed the criterion as
you
instructed and on entering the start and end dates the report opens
without
the parameter request; however the report does not contain any data.

Here is the criterion I had inserted originally:
=[forms]![Report Date Range]![Start Date] And =[forms]![Report Date
Range]![End Date]

With this I got data in the report, but had the parameter request.

With the original criterion, I opened the form, entered the dates,
then
ran
the query and got the parameter request. I did the same thing with
criterion
you provided and the query ran without the parameter request, but did
not
pull data from the table.

Here is code for the unbound field on the report.
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "rptReferralsV1"
If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then
Cancel = True
End If
End Sub

Also, on the form I originally had this code:
Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub

After one of the revisions we made, I got an error and debug highlited
this
code. I just deleted and the error msg cleared. Maybe I caused
another
problem when I deleted this code.

The complete original form code is futher down in the dialog.

I appreciate the time and effort you have given!

"Ken Snell [MVP]" wrote:

In the query, is the criterion expression that is reading the end
date
value
looking like this:
[Forms]![Report Date Range]![End Date]

If not, change it to the above.

If it does, then my first guess is that you've misspelled the form
name
or
the control name in the query's criterion expression. However, based
on
the
code excerpts that you've posted, that doesn't appear to be the case.

The parameter request could also be coming from the report itself --
a
control on the report may be using the form's control's value in a
control
source? See if you can identify whether it's the query or the report
that is
prompting the parameter window to show -- you can do this if you open
the
form itself directly from the database window, enter start and end
dates,
and then open the query (the one that the report uses) from the
database
window and see if you get the parameter.
--

Ken Snell
MS ACCESS MVP



"shep" wrote in message
...
Yes Sir! That did it. Thanks!

However, I still have something mixed up. I run the report and the
form
pops up. I enter the dates and click Preview and I get a box:
Enter Parameter Value Forms!Report Date Range!End Date and that
is a
place to enter date. I enter the End Date and the report runs.

So I suppose I have something wrong in the form code. Here is form
code:

Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub


Private Sub Preview_Click()
If IsNull([Start Date]) Or IsNull([End Date]) Then
MsgBox "You must enter both Start and End dates."
DoCmd.GoToControl "Start Date"
Else
If [Start Date] [End Date] Then
MsgBox "End date must be greater than Start Date."
DoCmd.GoToControl "Start Date"
Else
Me.Visible = False
End If
End If
End Sub
Would you be so kind as to heip me resolve this also? Many thanks

"Ken Snell [MVP]" wrote:

Sorry... it appears that I misread the original code. Try this:

If Not CurrentProject.AllForms("Report Date Range").IsLoaded Then

--

Ken Snell
MS ACCESS MVP

"shep" wrote in message
...
Thanks for your response. I revised per your instruction and it
worked;i.e.,
the form opened and accepted dates, but when I clicked PreviewI
got
error
Msg:
Runtime error 2467
The expression you entered refers to an object that is closed or
doesn't
exist

I clicked debug and it highlited the following code line, the
one I
modified
If Not CurrentProject.AllReports("Report Date Range").IsLoaded
Then

The only advantage I see in this procedure is that if user does
not
enter
an
end date that is later than the start date a prompt appears. So
this
is
not
something for which I have dire need. But if you see an easy
fix
I'll
try
it.

Thanks again, your response may help others as well.

"Ken Snell [MVP]" wrote:

For ACCESS 2002 and higher version(s), there is an IsLoaded
property
for
CurrentProject.AllReports object... perhaps this is what was
meant
to
be
used?

If Not CurrentProject.AllReports("Report Date Range").IsLoaded
Then

--

Ken Snell
MS ACCESS MVP


"Brendan Reynolds" wrote
in
message
...
There's no build-in function called IsLoaded (AccessObject
objects
have
an
IsLoaded property, but that is not what is being used here).
It's
probably
a custom function in a module in the template. To fix the
problem,
find
and import the module, or copy and paste the function into
one
of
your
own
standard modules.

--
Brendan Reynolds (MVP)

"shep" wrote in message
...

  #16  
Old September 12th, 2005, 05:14 PM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

You're welcome.

--

Ken Snell
MS ACCESS MVP

"shep" wrote in message
...
Once more, THANK YOU !!

"Ken Snell [MVP]" wrote:

Assuming that you want to get the dates from the form itself, use a
control
source like this for a textbox on the report:

=[forms]![Report Date Range]![Start Date] & " To " & [forms]![Report Date
Range]![End Date]

If you want to specifically format the date in some way (perhaps you want
month spelled out), you can use the Format function:

=Format([forms]![Report Date Range]![Start Date], "mmmm d, yyyy") & " To
" &
Format([forms]![Report Date Range]![End Date], "mmmm d, yyyy")
--

Ken Snell
MS ACCESS MVP




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
reminder notifications in a column L Mieth General Discussion 6 June 10th, 2005 11:00 AM
Access Mail Merge to Word.doc files ? RNUSZ@OKDPS Setting Up & Running Reports 1 May 18th, 2005 06:31 PM
Excel won't copy outside sheet Jack Sons General Discussion 6 May 17th, 2005 10:05 PM
Need Help In Printing Current Record in Specific Report RNUSZ@OKDPS Setting Up & Running Reports 1 May 16th, 2005 09:06 PM
trying to copy a sheet Jeff Gyarmathy General Discussion 1 September 15th, 2004 06:19 PM


All times are GMT +1. The time now is 09:53 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.