473,419 Members | 1,647 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,419 software developers and data experts.

Return codes with reports

Is it possible to return a code to Visual Basic when an Access reports
completes successfully and a different code when a report fails?

Thank you.
Nov 25 '05 #1
3 1653
Define "completes successfully".

If you mean that the report arrived at the printer and printed all pages
without a paper jam or running out of ink or paper or having a user switch
the printer off in the middle of the print run, no: there is not a simple
way to determine the status of the printer and the jobs that have been
passed to its print queue, including knowing whether the job made it out of
the printer's memory and onto the paper.

If you just wanted to know if the report opened successfully, Access returns
Error 2501 if the report was cancelled by the user or its Open or NoData
event. The example below returns True if the report was opened, or False if
it was cancelled. It also solves a couple of other issues with reports, such
as the WhereCondition not being applied if the report is already open,
changing the default to preview, dumping the useless Filter argument, and
passing a meaningful description of the filter in OpenArgs so you can
display it on the report. (Only A2002 and 2003 have OpenArgs for reports.)

Function OpenTheReport(strDoc As String,
Optional lngView As AcView = acViewPreview, _
Optional strWhere As String, _
Optional strDescrip As String, _
Optional lngWindowMode As AcWindowMode = acWindowNormal) As Boolean
On Error GoTo Err_Handler
'Purpose: Wrapper for opening reports.
'Arguments: View = acViewPreview or acViewNormal. Defaults to
preview.
' strWhere = WhereCondition. Passed to OpenReport.
' strDescrip = description of WhereCondition (passed as
OpenArgs).
' WindowMode = acWindowNormal or acDialog. Defaults to normal.
'Return: True if opened.
'Notes: 1. Filter propery of OpenReport is not supported.
' 2. Suppresses error 2501 if report cancelled.
Dim bCancel As Boolean
Dim strErrMsg As String

'If the report is alreay open, close it so filtering is handled
correctly.
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc, acSaveNo
End If

'Open the report
DoCmd.OpenReport strDoc, lngView, , strWhere, lngWindowMode, strDescrip
OpenTheReport = True

Exit_Handler:
Exit Function

Err_Handler:
Select Case Err.Number
Case 2501& 'Cancelled.
'do nothing
Case 2467& 'Bad report name.
MsgBox "No report named: " & strDoc, vbExclamation, "Cannot open
report."
Case Else
MsgBox "Error " & Err.Number & " - " & Err.Description
End Select
Resume Exit_Handler
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bookreader" <Bo***********@yahoo.com> wrote in message
news:vl********************************@4ax.com...
Is it possible to return a code to Visual Basic when an Access reports
completes successfully and a different code when a report fails?

Thank you.

Nov 26 '05 #2
On Fri, 25 Nov 2005 21:46:22 GMT, Bookreader <Bo***********@yahoo.com>
wrote:

What do you mean with "fails"? There is the NoData event you can use
when the criteria for the report cause 0 records to be displayed.

-Tom.

Is it possible to return a code to Visual Basic when an Access reports
completes successfully and a different code when a report fails?

Thank you.


Nov 26 '05 #3
On Sat, 26 Nov 2005 08:39:18 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Fri, 25 Nov 2005 21:46:22 GMT, Bookreader <Bo***********@yahoo.com>
wrote:

What do you mean with "fails"? There is the NoData event you can use
when the criteria for the report cause 0 records to be displayed.

-Tom.

Is it possible to return a code to Visual Basic when an Access reports
completes successfully and a different code when a report fails?

Thank you.

Thanks.
Nov 28 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Minor | last post by:
Hello... I'm interested in adding bar codes to printed reports. Does anyone have any recommendations as to what software they have incorporated into their applications to print bar codes? I'm...
2
by: Shaun | last post by:
Hi, I have a table of Locations around the country. My system produces reports based on these Locations. I also have a table containing Brick Codes e.g. Brick Post Code AB51 AB51 AB52 ...
6
by: Josh Mcfarlane | last post by:
I keep trying to get myself out of the return-code mindset, but it doesn't seem to work. They are suppose to get rid of if-then statements of return codes, but you still have to do an if statement...
1
by: kmnotes04 | last post by:
I have a data entry form that contains drop-down lists such as 'Assigned to:' with a list of staff member names. Those names end up as numerical codes in the main table ('ProjectInfo') of the...
3
by: c# beginner | last post by:
we are trying to standardize return codes across our .NET applications (that are soon to be developed.) What is the best practice for standardizing return codes? I know of only the following...
3
by: RdS | last post by:
Where do I find return codes for MS methods. For instance the filesystemobject methods. I need to know what methods return (error codes, etc. and what they mean). I have searched MSDN and of...
6
by: ljungers | last post by:
I have a memo field that is printed using Access Reports. Various fields from this table are used to fill in the heading and the body of the report uses that memo field. I now need to place some...
3
by: asearle | last post by:
Hallo everyone, I have a perl script which can return error codes. I have done this with, for example, 'exit 11;', which would (I imagine) send the exit code 11 (instead of 0) back to the calling...
1
by: Calder Coalson | last post by:
I was searching for ways to get the return value from os.system() calls, when I came across this from 6 years ago. I tried what was suggested in this thread, but output =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
1
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...
0
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...
0
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,...
0
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...

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.