472,344 Members | 2,325 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,344 software developers and data experts.

Open Report Code Error

114 100+
Hello,
I have a report that I open that pull its data from a form that builds a where string. Opening the report first opens the form, where I enter criteria, and then pulls matching records from a table, opens the report, and closes the form. The code on the report is below.

I used this code on a similar report that also pulled its data from a form (the difference was that that form supplied criteria to an actual query - my new form builds the where string from criteria itself). So, the problem is that I get an error:
Compile error: Sub or Function not defined when I try to open the report and it points to line 16 below (the code to cancel opening the report if the user selects the cancel button on the criteria form). If I comment out this line, the code works fine, opening the report properly. However, if the user selects the cancel button on the criteria form, the report still opens displaying all data.

Any ideas would be most appreciated! Thank you.
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Report_Close()
  4.   DoCmd.close acForm, "Survey Form"
  5. End Sub
  6.  
  7. Private Sub Report_Open(cancel As Integer)
  8. ' Set public variable to true to indicate that the report
  9. ' is in the Open event
  10.   bInReportOpenEvent = True
  11.  
  12. ' Open Survey Criteria Dialog
  13.   DoCmd.OpenForm "Survey Form", , , , , acDialog
  14.  
  15. ' Cancel Report if User Clicked the Cancel Button
  16.   If IsLoaded("Survey Form") = False Then cancel = True
  17.  
  18. ' Set public variable to false to indicate that the
  19. ' Open event is completed
  20.   bInReportOpenEvent = False
  21. End Sub
Oct 24 '07 #1
7 2856
Rabbit
12,516 Expert Mod 8TB
That's not how you use IsLoaded.

CurrentProject.AllForms("Name").IsLoaded

Also, you can't cancel the On Close event. But you can cancel the Unload event.
Oct 24 '07 #2
martin DH
114 100+
That's not how use IsLoaded.

CurrentProject.AllForms("Name").IsLoaded

Also, you can't cancel the On Close event. But you can cancel the Unload event.
So to stop the report from generating when the user presses "cancel" on the form...? I'm sorry, just not sure of all the various events at my disposal.
Thanks.
Oct 24 '07 #3
Rabbit
12,516 Expert Mod 8TB
Sorry, didn't realize you were trying to cancel the opening of a report. That part is fine as far as I can tell, you just have to change the IsLoaded part.
Oct 24 '07 #4
martin DH
114 100+
Sorry, didn't realize you were trying to cancel the opening of a report. That part is fine as far as I can tell, you just have to change the IsLoaded part.
A little confused...to what would I be changing it?
Oct 24 '07 #5
Rabbit
12,516 Expert Mod 8TB
A little confused...to what would I be changing it?
The IsLoaded syntax, you're using it wrong. There's an example in post #2 of how it's supposed to look.
Oct 24 '07 #6
martin DH
114 100+
The IsLoaded syntax, you're using it wrong. There's an example in post #2 of how it's supposed to look.
Sorry - I got it. Thanks, Rabbit. The report does not generate when the user selects "cancel" from the form now. Thank you!
Expand|Select|Wrap|Line Numbers
  1. ' Cancel Report if User Clicked the Cancel Button
  2.   If CurrentProject.AllForms("Survey Form").IsLoaded = False Then cancel = True
martin
Oct 25 '07 #7
Rabbit
12,516 Expert Mod 8TB
Sorry - I got it. Thanks, Rabbit. The report does not generate when the user selects "cancel" from the form now. Thank you!
Expand|Select|Wrap|Line Numbers
  1. ' Cancel Report if User Clicked the Cancel Button
  2.   If CurrentProject.AllForms("Survey Form").IsLoaded = False Then cancel = True
martin
Not a problem, goodluck.
Oct 25 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jenni | last post by:
Hi, A quick question. I have been battling with this code all morning, please help. Here is the code Dim fPath1 As String Dim fPath2 As...
4
by: Steve Jorgensen | last post by:
Hi all, This is actually not an issue of mine, but one a friend of mine told me about that I was able to confirm. Let's say you want a highly...
46
by: Steve | last post by:
Access97 Database The database is split into a frontend and backend and not connected to any other database. The database has an unbound report...
9
by: MLH | last post by:
Trouble is, it doesn't happen every time. Yesterday, for example, it happened only once and not again afterward. Some days ago, a similar...
2
by: Miguel | last post by:
I have reviewed the many postings on this topic and understand the principle, but am not sure where in my case to apply trapping an error. I have...
12
by: Orchid | last post by:
Hello all, I have different version of reports which used for different months. For example, I am using report version 1 up to September, but we...
2
by: BillCo | last post by:
Does anyone know if it is possible to integrate SQL Server Reporting Services Reports in an ADP? Is there a plugin or anything that can do this? I...
0
by: Kelii | last post by:
Evenlater, Yeah, I don't open the report in preview mode when I setup my recordsource, filters, or sorts. Before I give my solution, I would say...
4
by: Phil Stanton | last post by:
I am opening a report (in Preview) from a menu system I use the following code if there is no data in a report Private Sub Report_NoData(Cancel...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.