Copy Cat Ain't Working

G

Guest

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
 
B

Brendan Reynolds

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.
 
K

Ken Snell [MVP]

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
 
G

Guest

Thanks for your response

Brendan Reynolds said:
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.
 
G

Guest

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 said:
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>
 
K

Ken Snell [MVP]

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

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

Guest

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
 
K

Ken Snell [MVP]

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 said:
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 said:
Sorry... it appears that I misread the original code. Try this:

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

Larry Linson

For several versions, perhaps since the beginning of the sample databases,
there has been an IsLoaded procedure in one of the sample databases that
comes with Access. (I believe it is in Northwind.)

Larry Linson
Microsoft Access MVP
 
G

Guest

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 said:
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 said:
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 said:
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>

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.

:

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>


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)

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
 
K

Ken Snell [MVP]

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 said:
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 said:
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 said:
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

:

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>

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.

:

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>


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)

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
 
K

Ken Snell [MVP]

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 said:
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 said:
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 said:
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>



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

:

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>

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.

:

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>


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)

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
 
G

Guest

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 said:
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 said:
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 said:
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!

:

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>



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

:

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>

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.

:

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>


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)

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
 
K

Ken Snell [MVP]

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 said:
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 said:
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 said:
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>


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!

:

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>



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

:

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>

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.

:

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>


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)

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
 
G

Guest

Once more, THANK YOU !!

Ken Snell said:
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 said:
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 said:
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>


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>


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!

:

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>



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

:

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>

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.

:

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>


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.
 
K

Ken Snell [MVP]

You're welcome.

--

Ken Snell
<MS ACCESS MVP>

shep said:
Once more, THANK YOU !!

Ken Snell said:
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")
 

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