473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Report Snapshot Not Working with Timer Event

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 2356
ADezii
8,834 Expert 8TB
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
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 Expert 8TB
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
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
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...
1
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...
7
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...
8
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...
1
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...
3
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...
15
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...
10
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....
2
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.