473,654 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Report Snapshot Not Working with Timer Event

5 New Member
I am working with an Access 2003 database. Since adding a timer event to check for idle time to a form, a custom toolbar button that creates a snapshot has stopped working properly. Until the first time the timer event procedure is run, the button works fine, but after that, it produces an error "The Object Type argument for the action or method is blank or invalid."

The button runs a macro which runs the action "OutputTo" with the following settings:
Object Type: Report
Object Name: (blank)
Output Format: Snapshot Format

The code for the timer procedure is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer()
  2. '**********************************************************************
  3. '* This timer event procedure will shut down the application
  4. '* after a specified number of minutes of inactivity. Inactivity
  5. '* is measured based on how long a control remains the ActiveControl.
  6. '**********************************************************************
  7. Dim sngElapsedTime As Single
  8. Dim ctlNew As Control
  9. Dim currObject As String
  10. On Error Resume Next
  11.  
  12. Set ctlNew = Screen.ActiveControl
  13. If Err <> 0 Then
  14.     '* No activecontrol
  15.     sngElapsedTime = Timer - sngStartTime
  16.     Err.Clear
  17. Else
  18.     If ctlNew.Name = "InactiveShutDownCancel" Then
  19.         '* The warning form has appeared, and the cancel button
  20.         '* is the active control
  21.         sngElapsedTime = Timer - sngStartTime
  22.     Else
  23.         If ctlNew.Name = ctlSave.Name Then
  24.             '* Still at same control
  25.             sngElapsedTime = Timer - sngStartTime
  26.         Else
  27.             '* Some change has occured, we're at a new control
  28.             Set ctlSave = ctlNew
  29.             resetTimer
  30.         End If
  31.         If Err <> 0 Then
  32.             Set ctlSave = Screen.ActiveControl
  33.         End If
  34.     End If
  35. End If
  36. Err.Clear
  37.  
  38. On Error GoTo Err_Path
  39.  
  40. Set ctlNew = Nothing
  41.  
  42. If sngElapsedTime > (intMinutesUntilShutDown * 60) Then    ' First interval has passed; present idle warning.
  43.         DoCmd.OpenForm "frmInactiveShutDown", , , , , , sngElapsedTime & "|" & sngStartTime & "|" & intMinutesUntilShutDown & "|" & intMinutesWarningAppears
  44. End If
  45.  
  46. Exit Sub
  47. Err_Path:
  48.     MsgBox (ErrorLogRuntime(Error$, Screen.ActiveForm.Name, Screen.ActiveControl.Name))
  49.  
  50. Exit_Section:
  51. End Sub
  52.  

Any help is most appreciated.
Aug 17 '07 #1
4 2372
ADezii
8,834 Recognized Expert Expert
I am working with an Access 2003 database. Since adding a timer event to check for idle time to a form, a custom toolbar button that creates a snapshot has stopped working properly. Until the first time the timer event procedure is run, the button works fine, but after that, it produces an error "The Object Type argument for the action or method is blank or invalid."

The button runs a macro which runs the action "OutputTo" with the following settings:
Object Type: Report
Object Name: (blank)
Output Format: Snapshot Format

The code for the timer procedure is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer()
  2. '**********************************************************************
  3. '* This timer event procedure will shut down the application
  4. '* after a specified number of minutes of inactivity. Inactivity
  5. '* is measured based on how long a control remains the ActiveControl.
  6. '**********************************************************************
  7. Dim sngElapsedTime As Single
  8. Dim ctlNew As Control
  9. Dim currObject As String
  10. On Error Resume Next
  11.  
  12. Set ctlNew = Screen.ActiveControl
  13. If Err <> 0 Then
  14.     '* No activecontrol
  15.     sngElapsedTime = Timer - sngStartTime
  16.     Err.Clear
  17. Else
  18.     If ctlNew.Name = "InactiveShutDownCancel" Then
  19.         '* The warning form has appeared, and the cancel button
  20.         '* is the active control
  21.         sngElapsedTime = Timer - sngStartTime
  22.     Else
  23.         If ctlNew.Name = ctlSave.Name Then
  24.             '* Still at same control
  25.             sngElapsedTime = Timer - sngStartTime
  26.         Else
  27.             '* Some change has occured, we're at a new control
  28.             Set ctlSave = ctlNew
  29.             resetTimer
  30.         End If
  31.         If Err <> 0 Then
  32.             Set ctlSave = Screen.ActiveControl
  33.         End If
  34.     End If
  35. End If
  36. Err.Clear
  37.  
  38. On Error GoTo Err_Path
  39.  
  40. Set ctlNew = Nothing
  41.  
  42. If sngElapsedTime > (intMinutesUntilShutDown * 60) Then    ' First interval has passed; present idle warning.
  43.         DoCmd.OpenForm "frmInactiveShutDown", , , , , , sngElapsedTime & "|" & sngStartTime & "|" & intMinutesUntilShutDown & "|" & intMinutesWarningAppears
  44. End If
  45.  
  46. Exit Sub
  47. Err_Path:
  48.     MsgBox (ErrorLogRuntime(Error$, Screen.ActiveForm.Name, Screen.ActiveControl.Name))
  49.  
  50. Exit_Section:
  51. End Sub
  52.  

Any help is most appreciated.
With the Object Name being blank, the OutPutTo() Method will Default to the Active Object and prompt for an Output File. Once code execution shifts to the Timer Event, a Report is no longer the Active Object, and the Snapshot Format is not valid for the Active Control. I hope this makes sense. Specify the Object Name directly within the Macro and I'll bet the code will run fine. Let me know how you made out.
Aug 18 '07 #2
sophistiKate
5 New Member
Oh, great, thank you. That's what I've been suspecting, so it is really good to have that confirmed.

Unfortunately, I can't specify the report name, because the same macro is used for all reports. Is there a way around this? Can I specify at the end of my timer procedure to return to the previous active object? (I have searched and searched and found no information about setting the active object.)


With the Object Name being blank, the OutPutTo() Method will Default to the Active Object and prompt for an Output File. Once code execution shifts to the Timer Event, a Report is no longer the Active Object, and the Snapshot Format is not valid for the Active Control. I hope this makes sense. Specify the Object Name directly within the Macro and I'll bet the code will run fine. Let me know how you made out.
Aug 20 '07 #3
ADezii
8,834 Recognized Expert Expert
Oh, great, thank you. That's what I've been suspecting, so it is really good to have that confirmed.

Unfortunately, I can't specify the report name, because the same macro is used for all reports. Is there a way around this? Can I specify at the end of my timer procedure to return to the previous active object? (I have searched and searched and found no information about setting the active object.)
You may be able to make use of the PreviousControl Property, here is some sample code below will may be of assistance to you:
Expand|Select|Wrap|Line Numbers
  1. Public Function ProcessData() As Integer
  2.  
  3.     ' No previous control error.
  4.     Const conNoPreviousControl = 2483
  5.     Dim ctlPrevious As Control
  6.  
  7.     On Error GoTo Process_Err
  8.  
  9.     Set ctlPrevious = Screen.PreviousControl
  10.     If ctlPrevious.Name = "txtFinalEntry" Then
  11.         '
  12.         ' Process Data Here.
  13.         '
  14.         ProcessData = True
  15.     Else
  16.         ' Set focus to txtFinalEntry and display message.
  17.         Me!txtFinalEntry.SetFocus
  18.         ProcessData = False
  19.     End If
  20.  
  21. Process_Exit:
  22.     Set ctlPrevious = Nothing
  23.     Exit Function
  24.  
  25. Process_Err:
  26.     If Err = conNoPreviousControl Then
  27.         Me!txtFinalEntry.SetFocus
  28.         MsgBox "Please enter a value to process.", vbInformation
  29.         ProcessData = False
  30.     End If
  31.     Resume Process_Exit
  32. End Function
Aug 20 '07 #4
sophistiKate
5 New Member
Thank you for your help, and I will definitely hang on to this sample for future reference. I solved my problem eventually by using code in place of the macro as follows:
Expand|Select|Wrap|Line Numbers
  1.     Dim reportName As String
  2.  
  3.     reportName = Application.CurrentObjectName
  4.  
  5.     On Error Resume Next
  6.     DoCmd.OutputTo acOutputReport, reportName, acFormatSNP, , True
  7.  
It seems obvious to me that this shouldn't work, but it sure does. My project is all set, now, but if anyone has any ideas why this works when my original attempt (below) doesn't, I'm very curious and would love to hear about it:
Expand|Select|Wrap|Line Numbers
  1.     DoCmd.OutputTo acOutputReport, , acFormatSNP, , True
  2.  
Aug 22 '07 #5

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

Similar topics

5
1449
by: Jack | last post by:
Hi, We have a web application(asp based) without any report features. I have to build web reports. Right now, these reports are build on an Access 97 desktop application. The idea is to have our clients to print the reports via web application. I am wondering, what is the best way to develop web reports that would be exact same as Access 97 reports. Thanks in advance. Regards.
1
2839
by: Michael Wiseley | last post by:
I would like to make a user report automatically close after it has been left open in preview mode for more than 1 hour. I don't see a timer control or timer event in the report properties. Is there some way to make a report auto-close (time-out) in MS Access? -- Posted via http://dbforums.com
7
16582
by: Susan Bricker | last post by:
I would like to generate a report (I have the report working already) using MS/ACCESS 2000 and then have the ability to send the report as an email attachment to my colleagues. I have looked around in the MS/ACCESS Help facility and found that I can click on FILE (on the Menu Bar) and then click on SEND TO. This will generate, either, a 'Snapshot format' or 'Rich Text Format' file and send an email. Two problems: 1. Is it possible to...
8
6383
by: jbonifacejr | last post by:
This is my first day here, so please be patient. I do not know how to search very well so the search I tried to get the answer showed me topics from the year 2000 and they really don't cover what I want. I am trying to open MSAccess from ASP..I guess I would use server.createobject("Access.Application") OK, but where do i go from there to run a report and have it print to the default printer?
1
22765
by: ellenh | last post by:
I have read postings on the similar subject including the posting from 2003 shown below. This process works fine to display a single page snapshot report in PowerPoint. I need to display subsequent pages from the same snapshot file in subsequent slides in PowerPoint. I realize that it is possible to add VB code to the Snapshot Viewer Control and that there are properties such as .FirstPage, .NextPage, .LastPage, etc, But I can't find...
3
4923
by: sara | last post by:
Hi - I have a button that runs 2 reports. If there is no data on the report, I use the No Data event, and tell the user, and Cancel the execution of that report. However, if the first report has no data, the second report doesn't run. All execution stops. Is there a way in VBA to go on to the next report after the No Data?
15
3129
by: sara | last post by:
I am stuck. I have a report that I use in multiple places, so I call it with varying parameters (using the Where Clause in the code). I preview the report, send it to snap, then close the preview (the user can go to the server to see the snap view). Print, snap, then close is the only way I can snap with a Where clause. If there is No data that meets the criteria, I can cancel the print,
10
11748
by: sara | last post by:
Hi - Is it possible to hide the detail section of a report at run time? I have a report that prints all details, with summary lines. The user would like the report ALSO with just summary lines. It seems the simplest thing is to run the code (see below) once with the detail section showing, and a second time hiding the detail section. I can't figure out the code to do that and don't see it posted.
2
2110
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I am using reporting service with asp.net. I want to save a report snapshot in some time. How do I do this in asp.net? Is there any web service to do this? Thanks in advance! -Billy
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8294
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
8596
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5627
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
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
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
1
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1597
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.