473,698 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open Report Code Error

114 New Member
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 2924
Rabbit
12,516 Recognized Expert Moderator MVP
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 New Member
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 Recognized Expert Moderator MVP
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 New Member
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 Recognized Expert Moderator MVP
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 New Member
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 Recognized Expert Moderator MVP
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
8063
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 String fPath1 = "C:\Program Files\Microsoft Office\Office\EXCEL.EXE" fPath2 = "C:\Documents and Settings\jenniferr\My Documents\Generic
4
2001
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 customizable report, so you want to be able to do things like specify the ControlSource properties of TextBox controls on the report when it is run. The only time this works is in the Open event handler, but that works great. So, no problem, right?
46
6004
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 with 15 subreports. Some of the subreports include Excel charts in unbound object frames. When I add 3 additional subreports, I get the error message that Access can't open any more databases. Can anyone suggest what may be causing the error message. Thanks!
9
1778
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 situation. Today, well - I tried 7 times straight to open the report and each time, A97 shuts down. The seemingly hit 'n miss nature of the error is intriguing. All I've been able to determine is that if I allow the report to be opened from within code using this line... DoCmd.OpenReport...
2
4919
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 created a form to supply parameters to a report. I click on the command button to open the report, the form opens as it should and the parameters are entered. Upon clicking on "OK," the underlying query is executed. It is at this point, the the error message appears. The dialog box disappers as...
12
2233
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 have some design changes on the report for October, so I created report version 2. I want a same Command Button to open the appropriated version report for the specific month. I create a table with the following Fields: Month, ReportID, ReportToOpen (this is the exact report name). On a form,...
2
4769
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 have a hunch that the Web Viewer Active-X componant wont be up to the job. I've googled it but it seems to be slim pickings! I need to keep this ap as easy to ".NET-ise" as possible, so I'm trying to stay away from Access Reporting - as great as it actually is. Worst case I'll just shell to...
0
1568
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 that your code will be simpler if you drop the "Sort" button and simply include the sorts in the primary window rather than a window in dialog mode. For example, I use 5 sorts in my preview screen, the first sort is always enabled, the second sort only becomes enabled if the first is not null...
4
9664
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 As Integer) MsgBox "There are no errors in Membership Head of Families", vbInformation Cancel = True
0
8597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9012
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4358
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4611
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3034
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2319
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1992
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.