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: - Private Sub Form_Timer()
-
'**********************************************************************
-
'* This timer event procedure will shut down the application
-
'* after a specified number of minutes of inactivity. Inactivity
-
'* is measured based on how long a control remains the ActiveControl.
-
'**********************************************************************
-
Dim sngElapsedTime As Single
-
Dim ctlNew As Control
-
Dim currObject As String
-
On Error Resume Next
-
-
Set ctlNew = Screen.ActiveControl
-
If Err <> 0 Then
-
'* No activecontrol
-
sngElapsedTime = Timer - sngStartTime
-
Err.Clear
-
Else
-
If ctlNew.Name = "InactiveShutDownCancel" Then
-
'* The warning form has appeared, and the cancel button
-
'* is the active control
-
sngElapsedTime = Timer - sngStartTime
-
Else
-
If ctlNew.Name = ctlSave.Name Then
-
'* Still at same control
-
sngElapsedTime = Timer - sngStartTime
-
Else
-
'* Some change has occured, we're at a new control
-
Set ctlSave = ctlNew
-
resetTimer
-
End If
-
If Err <> 0 Then
-
Set ctlSave = Screen.ActiveControl
-
End If
-
End If
-
End If
-
Err.Clear
-
-
On Error GoTo Err_Path
-
-
Set ctlNew = Nothing
-
-
If sngElapsedTime > (intMinutesUntilShutDown * 60) Then ' First interval has passed; present idle warning.
-
DoCmd.OpenForm "frmInactiveShutDown", , , , , , sngElapsedTime & "|" & sngStartTime & "|" & intMinutesUntilShutDown & "|" & intMinutesWarningAppears
-
End If
-
-
Exit Sub
-
Err_Path:
-
MsgBox (ErrorLogRuntime(Error$, Screen.ActiveForm.Name, Screen.ActiveControl.Name))
-
-
Exit_Section:
-
End Sub
-
Any help is most appreciated.
4 2356
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: - Private Sub Form_Timer()
-
'**********************************************************************
-
'* This timer event procedure will shut down the application
-
'* after a specified number of minutes of inactivity. Inactivity
-
'* is measured based on how long a control remains the ActiveControl.
-
'**********************************************************************
-
Dim sngElapsedTime As Single
-
Dim ctlNew As Control
-
Dim currObject As String
-
On Error Resume Next
-
-
Set ctlNew = Screen.ActiveControl
-
If Err <> 0 Then
-
'* No activecontrol
-
sngElapsedTime = Timer - sngStartTime
-
Err.Clear
-
Else
-
If ctlNew.Name = "InactiveShutDownCancel" Then
-
'* The warning form has appeared, and the cancel button
-
'* is the active control
-
sngElapsedTime = Timer - sngStartTime
-
Else
-
If ctlNew.Name = ctlSave.Name Then
-
'* Still at same control
-
sngElapsedTime = Timer - sngStartTime
-
Else
-
'* Some change has occured, we're at a new control
-
Set ctlSave = ctlNew
-
resetTimer
-
End If
-
If Err <> 0 Then
-
Set ctlSave = Screen.ActiveControl
-
End If
-
End If
-
End If
-
Err.Clear
-
-
On Error GoTo Err_Path
-
-
Set ctlNew = Nothing
-
-
If sngElapsedTime > (intMinutesUntilShutDown * 60) Then ' First interval has passed; present idle warning.
-
DoCmd.OpenForm "frmInactiveShutDown", , , , , , sngElapsedTime & "|" & sngStartTime & "|" & intMinutesUntilShutDown & "|" & intMinutesWarningAppears
-
End If
-
-
Exit Sub
-
Err_Path:
-
MsgBox (ErrorLogRuntime(Error$, Screen.ActiveForm.Name, Screen.ActiveControl.Name))
-
-
Exit_Section:
-
End Sub
-
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.
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.
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: - Public Function ProcessData() As Integer
-
-
' No previous control error.
-
Const conNoPreviousControl = 2483
-
Dim ctlPrevious As Control
-
-
On Error GoTo Process_Err
-
-
Set ctlPrevious = Screen.PreviousControl
-
If ctlPrevious.Name = "txtFinalEntry" Then
-
'
-
' Process Data Here.
-
'
-
ProcessData = True
-
Else
-
' Set focus to txtFinalEntry and display message.
-
Me!txtFinalEntry.SetFocus
-
ProcessData = False
-
End If
-
-
Process_Exit:
-
Set ctlPrevious = Nothing
-
Exit Function
-
-
Process_Err:
-
If Err = conNoPreviousControl Then
-
Me!txtFinalEntry.SetFocus
-
MsgBox "Please enter a value to process.", vbInformation
-
ProcessData = False
-
End If
-
Resume Process_Exit
-
End Function
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: -
Dim reportName As String
-
-
reportName = Application.CurrentObjectName
-
-
On Error Resume Next
-
DoCmd.OutputTo acOutputReport, reportName, acFormatSNP, , True
-
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: -
DoCmd.OutputTo acOutputReport, , acFormatSNP, , True
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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....
|
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
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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
|
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...
| |