Open a report only after checking that it exists?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Cross-posted to macros...

I am doing something similar to neeraj in the question of 8/3/2005 (in
macros). I am
using a form to list possible reports to print. My question is, how can I
check to see if a report exists prior to opening it? I figured out how to
deal with an error if they didn't select a report, but am not sure how to
proceed if they select a report and it doesn't exist. This is in case the
report name is misspelled in the report listing or someone deleted the report
manually (we may be changing what reports exist in the future). I am
including neeraj's message only for reference. Thanks for your help.

neeraj's message of 8/3/2005

I have a macro written into the 'On Click' event of an OK button of a form.
This macro has got just one command row:Open Report. For the 'Report Name'
field, I am trying to pass the report name from the value selected from a
list box in that form. The Report Name field says:
[Forms]![myForm]![lstReports]
where [lstReports] is the name of that list box
When I hit the OK buton, it doesn't open the report and gives an error
message saying that
"The report name [Forms]![myForm]![lstReports] that you entered in either
the property sheet or the macro is either mispelled or doesn't exist"
How can I make this work?
 
Cross-posted to macros...

I am doing something similar to neeraj in the question of 8/3/2005 (in
macros). I am
using a form to list possible reports to print. My question is, how can I
check to see if a report exists prior to opening it? I figured out how to
deal with an error if they didn't select a report, but am not sure how to
proceed if they select a report and it doesn't exist. This is in case the
report name is misspelled in the report listing or someone deleted the report
manually (we may be changing what reports exist in the future). I am
including neeraj's message only for reference. Thanks for your help.

neeraj's message of 8/3/2005

I have a macro written into the 'On Click' event of an OK button of a form.
This macro has got just one command row:Open Report. For the 'Report Name'
field, I am trying to pass the report name from the value selected from a
list box in that form. The Report Name field says:
[Forms]![myForm]![lstReports]
where [lstReports] is the name of that list box
When I hit the OK buton, it doesn't open the report and gives an error
message saying that
"The report name [Forms]![myForm]![lstReports] that you entered in either
the property sheet or the macro is either mispelled or doesn't exist"
How can I make this work?

How are you getting the names of the reports to show on the form?
If you use a List box, then the RowSource should only show those
reports that are available, and not those that have been deleted.
Set the List Box RowSourceType to Table/Query.
Set the RowSource to:

SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=-32764)) ORDER BY
MSysObjects.Name;
 
Thank you for your reply. Right now it is set up as a query, but a query of
a table that lists available reports (this needs to be edited manually). I
inherited this database and that's how it was created originally so I left it
like that. The reports need to be in groups. So for example, I have a group
of audit reports, a group of personnel reports, etc. I need each form to
only list the reports available for that group. Is this possible using your
method? I currently have all my forms, tables, etc. together. I imagine if
I could move them to directories of some sort your method would work because
then I would only query for reports available in the audit directory for
example. I apologize if this seems basic. I'm teaching myself access as I
go from the help and websites...

fredg said:
Cross-posted to macros...

I am doing something similar to neeraj in the question of 8/3/2005 (in
macros). I am
using a form to list possible reports to print. My question is, how can I
check to see if a report exists prior to opening it? I figured out how to
deal with an error if they didn't select a report, but am not sure how to
proceed if they select a report and it doesn't exist. This is in case the
report name is misspelled in the report listing or someone deleted the report
manually (we may be changing what reports exist in the future). I am
including neeraj's message only for reference. Thanks for your help.

neeraj's message of 8/3/2005

I have a macro written into the 'On Click' event of an OK button of a form.
This macro has got just one command row:Open Report. For the 'Report Name'
field, I am trying to pass the report name from the value selected from a
list box in that form. The Report Name field says:
[Forms]![myForm]![lstReports]
where [lstReports] is the name of that list box
When I hit the OK buton, it doesn't open the report and gives an error
message saying that
"The report name [Forms]![myForm]![lstReports] that you entered in either
the property sheet or the macro is either mispelled or doesn't exist"
How can I make this work?

How are you getting the names of the reports to show on the form?
If you use a List box, then the RowSource should only show those
reports that are available, and not those that have been deleted.
Set the List Box RowSourceType to Table/Query.
Set the RowSource to:

SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=-32764)) ORDER BY
MSysObjects.Name;
 
I found an error trapping procedure one the web that displays the error
message and am using that rather than trying to avoid the error altogether.
Thank you for your help.

Liz Geho said:
Thank you for your reply. Right now it is set up as a query, but a query of
a table that lists available reports (this needs to be edited manually). I
inherited this database and that's how it was created originally so I left it
like that. The reports need to be in groups. So for example, I have a group
of audit reports, a group of personnel reports, etc. I need each form to
only list the reports available for that group. Is this possible using your
method? I currently have all my forms, tables, etc. together. I imagine if
I could move them to directories of some sort your method would work because
then I would only query for reports available in the audit directory for
example. I apologize if this seems basic. I'm teaching myself access as I
go from the help and websites...

fredg said:
Cross-posted to macros...

I am doing something similar to neeraj in the question of 8/3/2005 (in
macros). I am
using a form to list possible reports to print. My question is, how can I
check to see if a report exists prior to opening it? I figured out how to
deal with an error if they didn't select a report, but am not sure how to
proceed if they select a report and it doesn't exist. This is in case the
report name is misspelled in the report listing or someone deleted the report
manually (we may be changing what reports exist in the future). I am
including neeraj's message only for reference. Thanks for your help.

neeraj's message of 8/3/2005

I have a macro written into the 'On Click' event of an OK button of a form.
This macro has got just one command row:Open Report. For the 'Report Name'
field, I am trying to pass the report name from the value selected from a
list box in that form. The Report Name field says:
[Forms]![myForm]![lstReports]
where [lstReports] is the name of that list box
When I hit the OK buton, it doesn't open the report and gives an error
message saying that
"The report name [Forms]![myForm]![lstReports] that you entered in either
the property sheet or the macro is either mispelled or doesn't exist"
How can I make this work?

How are you getting the names of the reports to show on the form?
If you use a List box, then the RowSource should only show those
reports that are available, and not those that have been deleted.
Set the List Box RowSourceType to Table/Query.
Set the RowSource to:

SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=-32764)) ORDER BY
MSysObjects.Name;
 
Back
Top