473,554 Members | 2,913 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 2919
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
8058
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
1992
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...
46
5953
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...
9
1763
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...
2
4909
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...
12
2210
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...
2
4762
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...
0
1562
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,...
4
9648
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
7802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8042
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...
1
7563
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7889
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6145
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5155
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...
0
3560
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...
1
2020
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
0
841
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...

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.