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 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: - 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.
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: - 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 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.
|
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
|
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...
|
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?
|
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...
| |
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?
|
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,
|
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.
|
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: 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...
|
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,...
| |
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |