Você está na página 1de 14

08 January 98 Microsoft Access Integration Note Page 1

Product Category: Report Writers Support Category: Un-Supported


Product Abstract
Microsoft Access, part of the Microsoft Office Professional suite of applications, is a relational database
management system that structures your data in order to find answers easily, share timely information,
and build faster solutions that help you make better business decisions.
Access is used to combine data from several sources into a single database, and then produce reports of
that data. It integrates data from spreadsheets and other databases and is an easy way to find answers
and to share information over an Intranet and the Internet.
Since Access is a common application on many Windows desktops, it can be a convenient tool for
enhancing the reporting capabilities of the AR System User Tool. By sending information to an Access
database, reports of AR System data can be created and printed from an end-user PC.
Integration Summary
By using Microsoft Access to view the information stored within an Action Request System (AR System)
database, you can use the standard Access functions to create reports and print copies of the data to a
printer.
Microsoft Access views the AR System database using the Microsoft Open Database Connectivity
(ODBC) technology. Active Links in the AR System User Tool can be defined to automatically launch
Access and run predefined reports or screen print macros at the press of a button.
Figure 1 Action Request System Microsoft Access Integration
Action Request System

Integration Note
Remedy
C o r p o r a t i o n
TM
Action
Request
System
Microsoft
Access
DDE Launch
ODBC
Hardcopies
Reports
AR System
database
Access
database
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 2
Support For Integration
The work described in this Integration Note is Un-Supported. Both Remedy and Microsoft support
their respective products and interfaces, but the examples provided in this Integration Note are not
supported.
The technology needed for this work is described in several AR System documents, the Visual Basic
Guide and the MS Access Users Guide. This Integration Note is provided as a convenience to help you
get started with the integration of the AR System and the Access application.
System Requirements
1. Action Request System Version 2.0 or greater (AR System API package not required), using a SQL
database for data storage.
2. Microsoft Access (Integration based on version 7.0 but is compatible with earlier versions)
3. ODBC drivers for both Microsoft Access and the database system being used by the AR System
Server.
This integration uses Open Database Connectivity (ODBC). This integration requires some Visual Basic
coding and some database administration skills.
This Integration Note assumes that you are familiar with creating Microsoft Access applications using
the programming tools provided with Microsoft Access. For more information about Visual Basic for
Applications, please refer to the Access manual Building Applications.
Note: Visual Basic for Applications (used in Microsoft Access for Windows 95, version 7.0) is called
Access Basic in earlier versions. For more information about Access Basic, please refer to the
Introduction to Programming manual in Microsoft Access version 1.x, or the Building Applications
manual in version 2.0.
Contact Information
Microsoft Corporation Remedy Corporation
One Microsoft Way 1505 Salado Drive
Redmond, WA 98052-6399 USA Mountain View, CA 94043 USA
+(206) 635-7070 [tel] +(650) 903-5200 [tel]
+(206) 936-7329 [fax] +(650) 903-9001 [fax]
http:/ / www.microsoft.com info@remedy.com
http:/ / www.remedy.com
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 3
Integration Details
As is the case with most integration projects, there is no single, unique way to integrate the AR System
and Microsoft Access. The products themselves offers several integration alternatives, and specific user
requirements for a given organization add other permutations. This section describes the integration
details for a typical scenario. You may need to adapt this to your environment.
Overview
There are two ways you can integrate the AR System and Microsoft Access. You can choose to
implement either or both of these methods, and instructions for each are provided below. The two
methods are:
1. Using Access as a report writer. This integration requires integration between Access and the
database used by the AR System, as well as between the applications themselves. Using Active
Links, the desired report can be launched from the AR System User Tool, which executes and
displays it using Access.
2. Using Access to print hard copies of one or more AR System database entries (e.g., trouble
tickets). This integration involves creating a macro in the AR User Tool to export data, an Active
Link to launch Access, and an Access macro to print the data to a printer.
Using Access as a Report Writer
The majority of the integration work for this scenario will be done within Access.
In essence, the parts of the AR System database from which reports are to be extracted are copied into a
new Access database, which is then linked to the original. This new database is then used by Access to
generate reports. Linking the Access database to the AR System database ensures that the Access data is
up-to-date and consistent with the most current information in the AR System.
One point of interest to note is that in the AR System database, values for date/ time fields are stored in
the UNIX time format (number of seconds since Jan 1, 1970). This requires a conversion procedure in
Access so that these fields are displayed properly on the report. A similar conversion is required for
selection fields (such as Status), which are stored as numbers rather than words. Examples of these
conversion procedures are included in Appendix B. Diary and Status History fields will also require
conversion, since these fields are formatted with control characters. Details about the format of these
fields are available in the AR System Programmers Guide.
The AR System will pass the report type to be printed to Access using an execution string. The
execution string is a command string that can be passed to Access when it is started. Access, using a
Visual Basic macro, will examine the execution string to determine the report to be selected and printed.
An example of such a Visual Basic routine is given in Appendix A.
Acquiring ODBC Drivers
Before this integration can be accomplished, the necessary ODBC drivers must be installed. Microsoft
Access ODBC drivers can be installed by selecting the appropriate options when installing Access.
Alternatively, they can be obtained free of charge from Microsoft. In addition to the Microsoft Access
ODBC drivers, the necessary ODBC drivers for the database underlying the AR System must be
obtained. These are readily available from the respective database vendor.
Before using Access, an ODBC driver must be configured so that the AR System database becomes an
ODBC data source. To do this, you will need to know some information about the AR System
database, such as a valid database user name and password. This information can be obtained from
your AR System administrator or system administrator.
After installing the ODBC drivers you should have an icon or program group called ODBC, and
within this group you should have an icon representing the ODBC Administrator tool. ODBC data
sources are configured using this tool. To add a new data source, start the ODBC Administrator tool,
and press the Add button. From the list of available drivers, select the one named SQL Server. At
this point, you will need to enter the specific parameters for your AR System database. Complete the
necessary fields, and press the Options button. When prompted for the name of the AR System
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 4
database (as shown in Figure 2), enter ARSystem. This is the default name for the AR System
database.
After completing this configuration, you will have a new ODBC data source, which you can use within
Access to view your AR System data.
Figure 2 Configuring an ODBC data source
Database Administration Tasks
A database administrator will be required to create a group that will contain those users of the AR
System who will be running reports created in Access. Each user will be required to be a member of this
group. Ensure that both the group and individual(s) have the necessary privileges to the objects
required to run reports created in Access.
Microsoft Access Development Setup
It is recommended that a separate database be created within Access solely for the purpose of Remedy
AR System integration. In this Integration Note, it is assumed that this database has been named
ARSDB.
After creating this database, you will need to create a new table. This is accomplished by selecting
New from the Table tab: a pop-up window will be displayed. By selecting Link Table, the data in
the new table will be linked to the data in the original AR System table, ensuring that the data in ARSDB
is always current. See Figure 3.
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 5
Figure 3 Creating an Access "link table"
Press the OK button -- another pop-up window will be presented. Under Files of Type select
ODBC Database(s). From the next pop-up window, select the ODBC Data Source that was created
earlier, and enter the user name and password required to access the AR System database. In the
development of this Integration Note, Microsoft SQL Server was used as the underlying AR System
database. You should log in as a database user with appropriate permissions to the AR System database
and its objects. Note that this will be an account within the database itself and not an AR System
account. Next, select the appropriate database SQL View.
If you have access to the documentation for AR System version 3.0 or higher, you may wish to consult
volume 2 of the AR System Administrators Guide, which describes the AR System database structure
for your underlying database. The name of the SQL View will be the same as its corresponding AR
System form (schema), but with underscore characters (_) replacing spaces in the name.
Microsoft Access Development
After accomplishing the above steps, you should have a linked table in Access with which you can
develop reports. The largest hurdle to overcome now is passing parameters to Access to selectively
print desired reports. The best way to do this is by utilizing the /cmd command line argument when
starting Access, and using Visual Basic to parse the string to determine which report to print.
Since you cannot launch specific Access modules (which contain the macros) directly from the command
line, you must create a Visual Basic macro that will execute every time the database file is opened. If
you are familiar with Access you will know that naming the macro Autoexec will achieve this.
Within this Autoexec macro, you will launch the module to run the desired report. Within this
module you can take advantage of the system function Command. Command contains the string
that follows the /cmd portion of the command line which was used to start Access.
Figure 4 shows the sequence of events when Access is launched from the AR System User Tool.
Figure 4 Using macros to run a report
At this point, it is assumed that some reports have been created in Access. This Integration Note will
not discuss the creation of the reports. However, Appendix B includes sample code to convert Unix
time into a more readable format and to convert AR System selection values to a readable format. It
should be pointed out that for the purpose of this Integration Note, two Access reports were created,
one for a single AR System record, and one for multiple records.
AR System launches
Access with /cmd
argument.
Access opens MDB file
and runs Autoexec
macro.
Report module runs
macro to parse /cmd
string, and select report
to print
Autoexec macro runs
Report modules
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 6
Please note that this is only one of many possible integration paths, and there may be numerous other
approaches that are not explored in this Integration Note.
AR System Integration Requirements
The amount of work involved on the AR System side is very little compared to that of Access. At a
minimum, all that is required on the AR System side is an Active Link that will execute a Run Process
action, to launch Access when the user presses a button. The example given below is somewhat more
involved than this, but is still relativity easy. The following assumes that two reports have been created
in Access, and that AR System users need to able to run these reports from a button on an AR System
form or schema. This will be accomplished by creating a field with an attached menu. The menu will
contain available reports, and buttons will run Access and place the selected report in the /cmd section
of the command line. The following definitions are for the four objects required for this functionality:
Menu DemoHD:Reports
This menu presents the AR System user with a list of the predefined Access
reports that can be generated. The two reports shown here are examples only:
you will need to define your own reports and place their names in this menu.
Menu type Character
Menu definition Access
Label: Single Ticket Value: MSA Single Ticket
Label: All Tickets Value: MSA All Tickets
Active Link DemoHD:MSAReportAll
This Active Link executes when the All Tickets report has been selected and the
Report button is pressed. Its action is to launch Access and pass the string
All using the / cmd command line argument.
Schema Name (your schema name)
Execute On Button Report
Run If (your menu field) = MSA All Tickets
Actions Run Process:
C:\MSOffice\Access\MSAccess.exe c:\mydir\arsdb.mdb /cmd All
Active Link DemoHD:MSAReportSingle
This Active Link executes when the Single Ticket report has been selected and
the Report button is pressed. Its action is to launch Access and pass a string
identifying the Call Id of the ticket to report using the / cmd command line
argument.
Schema Name (your schema name)
Execute On Button Report
Run If Call ID != $NULL$ AND (your menu field) = MSA Single Ticket
Actions Run Process:
C:\MSOffice\Access\MSAccess.exe arsdb.mdb /cmd Single $Call Id$
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 7
Active Link DemoHD:MSAReportNull
This Active Link executes when the Single Ticket report has been selected, but
no Call Id is available on the form. Its action is to display a warning message to
the user.
Schema Name (your schema name)
Execute On Button Report
Run If Call ID = $NULL$ AND (your menu field) = MSA Single Ticket
Actions Message:
You must either select a call ticket, or placed a Call Id in the
Call ID field, for this action to work.
With these four objects created, you should now have the capability to run Access reports. As new
reports are created in Access, you can simply add them to the menu and create the necessary Active
Link to run the report. Once again, it is emphasized that this is only one approach to integrating these
products. Other approaches and other workflow may also be used to accomplish the same objectives.
Using Access to Print Hard Copies
AR System users often need the ability to print a copy of one or more entries in a schema. This section of
this Integration Note explains how Access can be used to achieve this, creating hard copies which can
emulate the layout of a schema or provide a different layout.
The integration is achieved using several components. A button on an AR System is used to trigger an
Active Link, which executes two actions: the first action runs a pre-defined AR System report that
exports data into a text file; the second action uses a DDE command to launch Access, import the text
file, and print a hard copy of the data.
The steps outlined below illustrate how you can print a single schema entry simply by pressing a button.
With minor modifications, the same methods can be used to print multiple entries with a single button
press.
Figure 5 Using Access to Print AR System Entries
Creating a Report Macro for Exporting Data
Using the AR System User Tool, record a macro that exports a single entry into a text file. This can be
achieved using the following steps:
1. Open the desired schema in Query mode, and select Start Recording from the macro menu.
2. Type a parameter name such as $entryid$ into the Entry-Id field of the schema.
3. Select Report from the Query menu. You will be asked to supply a value for the $entryid$
parameter in order to proceed: enter any value here, it will not be stored in the macro.
AR User
1. Active Link runs pre-
defined macro that
creates a report file.
2. DDE command
launches Access
CSV File
MS Access Printer
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 8
4. In the Report window, design a report that includes all the fields you wish to appear in the printed
hard copy. Press the File button to store the report data into a file. Make sure the file is saved in
the Comma Separated Value (CSV) format. Also be sure to deselect the Append check box, and
deselect the Prompt for file name check box.
5. Select Stop Recording from the Macro menu and save the macro.
Whenever this macro is executed and passed an Entry ID parameter value, it will overwrite the text file
you specified in step 4 with the contents of the schema entry with the corresponding Entry ID.
Creating the Print Screen Active Link
Use the AR Admin Tool to add a new button to the schema to be printed, and label the button Print
Screen or something similar. You must then create a new Active Link that is executed whenever that
button is pressed. This Active Link must perform two actions:
1. The first action runs the macro recorded earlier, passing the contents of the Entry-Id field as the
value for the macro parameter.
2. The second action runs a DDE command which activates Access. For this DDE command, you must
specify the following parameters:
Action: Execute
Topic: Name of the database
e.g. helpdesk.mdb
Path: The path to Access, followed by the path to the database
e.g. c:\ msoffice\ access\ access.exe c:\ data\ helpdesk.mdb
Command: This represents an Access menu selection of OPEN.
The path names to the database files can be fixed, as shown here, or generalized using a parameter
that is passed from a schema field.
Creating the Access Database
Within Access, you must define three objects:
1. A table, to store the data from the AR System.
2. A report, to format the data
3. A macro, to run the report and print the data.
Each of these parts is explained in detail below.
A table to store the data from the AR System.
You can create this table by hand, but you must ensure that the field names in this table match exactly
the field names in the schema from which the data is being exported. All the field types should be
text (except diary fields, which should be of type memo). Beawarethat theAR System allows periods
(.) in field names but Access does not. Avoid using fields that includeperiods as part of their names if you intend
to useAccess for printing and/or reporting purposes.
An example illustration showing the creation of an Access table is shown in Figure 6.
A report to format the data.
This report can be created using the Access Report Wizard to quickly design a single-column report,
based on the table designed in the previous step. In the report design view, you can rearrange the fields
and add additional formatting information such as lines, boxes, logos, etc.
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 9
Figure 6 Creating a new Access database table
A macro to import and print the data.
This macro needs to be named Autoexec, since it must be executed whenever the Access database is
opened (any Access macro with this name will be executed in this manner). The macro must be written
to delete all current data in the database, import the data from the AR System export file, print the
report to a printer, and then close the Access application. An example macro containing six actions is
shown below:
Action Name Description and Parameters
Hourglass Displays the hourglass symbol to the user to indicate that an action is in process.
Echo Hides all macro activity from the user until the macro completes.
Echo on = NO
Status Bar Text = Please wait Screen Printing
RunSQL Deletes all records from the database table.
SQL Statement = DELETE DISTINCTROW <table>.* from <table>;
TransferText Imports the CSV file exported from the AR System User Tool.
Transfer Type = Import Delimited
Table Name = <table>
File Name = <file_from_aruser_report>
Has Field Names = Yes
OpenReport Prints a report of a record
Report Name = <reportname>
View = Print
Quit Closes the Access application
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 10
Options = Exit
When the Autoexec macro is in place, Access performs the actions of this macro before passing control
to the user. If you need to open a database without the Autoexec macro executing, hold down the SHIFT
key while double-clicking the database file name the database will open without running the macro
and will appear minimized on the screen.
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 11
Appendix A
This procedure is used as the integration method between the AR System and Access/ MS SQL. It
should be noted that this is not limited to MS SQL Server. This same procedure will work for any
database which supports ODBC. The logic used for this integration is that the request comes from the
AR System and the request contains a Report Type. The command line option is used when calling
Access -- this procedure parses the command line and runs the requested report. For each new report,
simply add its section to the select case statement.
We recognize that this is one implementation, and there are many other approaches that can be
implemented. The overall intent is to show that integration is possible and provides a starting point.
Function CheckCommandLine()
'This procedure is used as the integration method between the Remedy AR System and
'Access/MS SQL. It should be noted that this is not limited to MS SQL.
'This same procedure will work for any RDBMS which supports ODBC.
'The logic used for this integration is that the request comes from
'the AR System and the request contains a Report Type. The command line option is used
'when calling Access, this procedure parses the command line and runs the
'requested report. For each new report simply add its section to the select
'case statement.
'We recognize that this is one implementation and there are many other
'approaches which can be implemented. The overall intent is to show that
'integration is possible and provides a starting point for developers.
Dim db As Database
Dim CharCnt As Integer
Dim Ticket_Nbr As String
Dim Report_Type As Variant
Set db = DBEngine(0)(0)
'Provide a graceful exit in case of runtime errors.
On Error GoTo Exit_Reports
'This will prevent errors occurring when opening Remedy.MDB
'when not called from Remedy the AR System.
If Command = "" Then
GoTo Exit_Reports
End If
'Parse the command line for the report type
CharCnt = 1
Do While Right(Report_Type, 1) <> " "
Report_Type = Left(Command, CharCnt)
CharCnt = CharCnt + 1
Loop
'Strip out the white space
Report_Type = Left(Report_Type, CharCnt - 2)
Select Case Report_Type
Case "Single"
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 12
'Parse the command line for the Call Id to report on
'this will be accomplished by reading each character from
'the Right until a space is detected.
CharCnt = 1
Do While Left(Ticket_Nbr, 1) <> " "
Ticket_Nbr = Right(Command, CharCnt)
CharCnt = CharCnt + 1
Loop
'Strip out the white space
Ticket_Nbr = Right(Ticket_Nbr, CharCnt - 2)
'Launch the report specifying the Call Id
DoCmd.OpenReport "Helpdesk Single Ticket", acPreview, , "[Call_Id] ='" & Ticket_Nbr & "'"
Case "All"
'Launch the report
DoCmd.OpenReport "Helpdesk Call Tickets", acPreview
End Select
Exit_Reports:
End Function
Appendix B
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 13
Since the AR System stores all date/ time values in Unix time format (the number of seconds since
January 1, 1970) we will use the dateadd function to format a readable date. Since this is GMT, you
will need to provide an offset according to your local time zone. The calling object provides the variable
UNIX_Time. In our case it is the control on the report that is a date/ time field.
Function Calc_Time(UNIX_Time)
Dim CorrectDate As Variant
CorrectDate = DateAdd("s", UNIX_Time, #1/1/70#)
Calc_Time = CorrectDate
End Function
The Format_Status function is used to compensate for the way the AR System stores selection values
in the database tables (i.e., as integers instead of character strings). It is necessary to provide some type
of conversion so meaningful reports can be generated. It should be noted for each selection type field
you place on a report or form, you will need to use some similar type of conversion. Again, as in the
date/ time conversion, this function must be passed a value to perform the conversion.
Function Format_Status(Status_NBR)
Select Case Status_NBR
Case 0
Format_Status = "New"
Case 1
Format_Status = "Assigned"
Case 2
Format_Status = "Work In Progress"
Case 3
Format_Status = "Pending Info"
Case 4
Format_Status = "Reassigned"
Case 5
Format_Status = "Escalated"
Case 6
Format_Status = "Closed"
End Select
End Function
Remedy Corporation
08 January 98 Microsoft Access Integration Note Page 14
Endnotes
Integration Notes are produced by Remedy Corporation as a convenience for our customers. Remedy has made an effort to ensure
that the information contained in this document is accurate, but does not guarantee any accuracy now or in the future.
Remedy, the Remedy logo, Action Request System, Flashboards, and ARWeb are trademarks of Remedy Corporation. Any other
trademarks or service marks mentioned in this document are the property of their respective owners and are hereby recognized.
Remedy Corporation 1998
Rights to reproduce this document by permission of Remedy Corporation only.
Thanks to Donald Culp for information on using Access as a screen printing device for the AR System.
n:\ partners\ ms_accss\ access6.doc
PN: AXA-IN-41-0198

Você também pode gostar