+ All Categories
Home > Documents > MS Access Integration Note

MS Access Integration Note

Date post: 02-Jun-2018
Category:
Upload: gunalprasadg
View: 217 times
Download: 0 times
Share this document with a friend

of 14

Transcript
  • 8/10/2019 MS Access Integration Note

    1/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 databasemanagement 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 ofthat data. It integrates data from spreadsheets and other databases and is an easy way to find answersand 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 forenhancing the reporting capabilities of the AR System User Tool. By sending information to an Accessdatabase, 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 aprinter.

    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 launchAccess 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 NoteRemedyC o r p o r a t i o nTM

    Action

    Request

    System

    Microsoft

    AccessDDE Launch

    ODBC

    Hardcopies

    Reports

    AR Systemdatabase

    Accessdatabase

  • 8/10/2019 MS Access Integration Note

    2/14

    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 supporttheir respective products and interfaces, but the examples provided in this Integration Note are notsupported.

    The technology needed for this work is described in several AR System documents, the Visual BasicGuide and the MS Access Users Guide. This Integration Note is provided as a convenience to help youget 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 SQLdatabase 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 SystemServer.

    This integration uses Open Database Connectivity (ODBC). This integration requires some Visual Basiccoding and some database administration skills.

    This Integration Note assumes that you are familiar with creating Microsoft Access applications usingthe programming tools provided with Microsoft Access. For more information about Visual Basic forApplications, please refer to the Access manual Building Applications.

    Note: Visual Basic for Applications (used in Microsoft Access for Windows 95, version 7.0) is calledAccess Basic in earlier versions. For more information about Access Basic, please refer to theIntroduction to Programming manual in Microsoft Access version 1.x, or the Building Applicationsmanual in version 2.0.

    Contact Information

    Microsoft Corporation Remedy Corporation

    One Microsoft Way 1505 Salado DriveRedmond, 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 [email protected]

    http://www.remedy.com

  • 8/10/2019 MS Access Integration Note

    3/14

    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 Systemand Microsoft Access. The products themselves offers several integration alternatives, and specific userrequirements for a given organization add other permutations. This section describes the integrationdetails 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 toimplement either or both of these methods, and instructions for each are provided below. The twomethods are:

    1. Using Access as a report writer. This integration requires integration between Access and thedatabase used by the AR System, as well as between the applications themselves. Using ActiveLinks, the desired report can be launched from the AR System User Tool, which executes anddisplays it using Access.

    2. Using Access to print hard copies of one or more AR System database entries (e.g., troubletickets). This integration involves creating a macro in the AR User Tool to export data, an ActiveLink to launch Access, and an Access macro to print the data to a printer.

    Using Access as a Report WriterThe 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 anew Access database, which is then linked to the original. This new database is then used by Access togenerate reports. Linking the Access database to the AR System database ensures that the Access data isup-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 inthe UNIX time format (number of seconds since Jan 1, 1970). This requires a conversion procedure inAccess so that these fields are displayed properly on the report. A similar conversion is required forselection fields (such as Status), which are stored as numbers rather than words. Examples of theseconversion procedures are included in Appendix B. Diary and Status History fields will also requireconversion, 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. Theexecution string is a command string that can be passed to Access when it is started. Access, using aVisual 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. MicrosoftAccess 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 AccessODBC drivers, the necessary ODBC drivers for the database underlying the AR System must beobtained. 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 anODBC data source. To do this, you will need to know some information about the AR Systemdatabase, such as a valid database user name and password. This information can be obtained fromyour AR System administrator or system administrator.

    After installing the ODBC drivers you should have an icon or program group called ODBC, andwithin this group you should have an icon representing the ODBC Administrator tool. ODBC datasources 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. Atthis point, you will need to enter the specific parameters for your AR System database. Complete thenecessary fields, and press the Options button. When prompted for the name of the AR System

  • 8/10/2019 MS Access Integration Note

    4/14

    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 Systemdatabase.

    After completing this configuration, you will have a new ODBC data source, which you can use withinAccess 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 ARSystem who will be running reports created in Access. Each user will be required to be a member of thisgroup. Ensure that both the group and individual(s) have the necessary privileges to the objectsrequired 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 RemedyAR System integration. In this Integration Note, it is assumed that this database has been namedARSDB.

    After creating this database, you will need to create a new table. This is accomplished by selectingNew from the Table tab: a pop-up window will be displayed. By selecting Link Table, the data inthe new table will be linked to the data in the original AR System table, ensuring that the data in ARSDBis always current. See Figure 3.

  • 8/10/2019 MS Access Integration Note

    5/14

    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 selectODBC Database(s). From the next pop-up window, select the ODBC Data Source that was createdearlier, and enter the user name and password required to access the AR System database. In thedevelopment of this Integration Note, Microsoft SQL Server was used as the underlying AR Systemdatabase. 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 Systemaccount. 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 consultvolume 2 of the AR System Administrators Guide, which describes the AR System database structurefor your underlying database. The name of the SQL View will be the same as its corresponding ARSystem 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 candevelop reports. The largest hurdle to overcome now is passing parameters to Access to selectivelyprint desired reports. The best way to do this is by utilizing the /cmdcommand line argument whenstarting 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 commandline, you must create a Visual Basic macro that will execute every time the database file is opened. Ifyou 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 thismodule you can take advantage of the system function Command. Command contains the stringthat follows the /cmdportion 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 willnot discuss the creation of the reports. However, Appendix B includes sample code to convert Unixtime into a more readable format and to convert AR System selection values to a readable format. Itshould 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 launchesAccess with /cmd

    argument.

    Access opens MDB fileand runs Autoexec

    macro.

    Report module runsmacro to parse /cmd

    string, and select reportto print

    Autoexec macro runsReport modules

  • 8/10/2019 MS Access Integration Note

    6/14

    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 otherapproaches 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 aminimum, all that is required on the AR System side is an Active Link that will execute a Run Processaction, 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 createdin Access, and that AR System users need to able to run these reports from a button on an AR Systemform or schema. This will be accomplished by creating a field with an attached menu. The menu willcontain available reports, and buttons will run Access and place the selected report in the /cmdsectionof 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 Accessreports 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 AccessLabel: 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 theReport button is pressed. Its action is to launch Access and pass the stringAll using the /cmd command line argument.

    Schema Name (your schema name)

    Execute On Button ReportRun 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 andthe Report button is pressed. Its action is to launch Access and pass a stringidentifying the Call Id of the ticket to report using the /cmd command lineargument.

    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$

  • 8/10/2019 MS Access Integration Note

    7/14

    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, butno Call Id is available on the form. Its action is to display a warning message tothe user.

    Schema Name (your schema name)

    Execute On Button Report

    Run If Call ID = $NULL$ AND(your menu field) = MSA Single TicketActions Message:

    You must either select a call ticket, or placed a Call Id in theCall ID field, for this action to work.

    With these four objects created, you should now have the capability to run Access reports. As newreports are created in Access, you can simply add them to the menu and create the necessary ActiveLink to run the report. Once again, it is emphasized that this is only one approach to integrating theseproducts. 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 ofthis Integration Note explains how Access can be used to achieve this, creating hard copies which canemulate 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 anActive Link, which executes two actions: the first action runs a pre-defined AR System report thatexports data into a text file; the second action uses a DDE command to launch Access, import the textfile, 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 buttonpress.

    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 beachieved 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 thatcreates a report file.

    2. DDE commandlaunches Access

    CSV File

    MS Access Printer

  • 8/10/2019 MS Access Integration Note

    8/14

    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 printedhard copy. Press the File button to store the report data into a file. Make sure the file is saved inthe Comma Separated Value (CSV) format. Also be sure to deselect the Append check box, anddeselect 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 fileyou 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 PrintScreen or something similar. You must then create a new Active Link that is executed whenever thatbutton 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 thevalue for the macro parameter.

    2. The second action runs a DDE command which activates Access. For this DDE command, you mustspecify the following parameters:

    Action: Execute

    Topic: Name of the database

    e.g. helpdesk.mdbPath: 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 parameterthat 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 exactlythe field names in the schema from which the data is being exported. All the field types should betext (except diary fields, which should be of type memo). Be aware that the AR System allows periods(.) in field names but Access does not. Avoid using fields that include periods as part of their names if you intendto use Access 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 fieldsand add additional formatting information such as lines, boxes, logos, etc.

  • 8/10/2019 MS Access Integration Note

    9/14

    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 isopened (any Access macro with this name will be executed in this manner). The macro must be writtento delete all current data in the database, import the data from the AR System export file, print thereport to a printer, and then close the Access application. An example macro containing six actions isshown 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 .* from ;

    TransferText Imports the CSV file exported from the AR System User Tool.

    Transfer Type = Import Delimited

    Table Name =

    File Name =

    Has Field Names = Yes

    OpenReport Prints a report of a record

    Report Name =

    View = Print

    Quit Closes the Access application

  • 8/10/2019 MS Access Integration Note

    10/14

    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 controlto the user. If you need to open a database without the Autoexec macro executing, hold down the SHIFTkey while double-clicking the database file name the database will open without running the macroand will appear minimized on the screen.

  • 8/10/2019 MS Access Integration Note

    11/14

    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. Itshould be noted that this is not limited to MS SQL Server. This same procedure will work for anydatabase which supports ODBC. The logic used for this integration is that the request comes from theAR System and the request contains a Report Type. The command line option is used when callingAccess -- 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 beimplemented. 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"

  • 8/10/2019 MS Access Integration Note

    12/14

    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

  • 8/10/2019 MS Access Integration Note

    13/14

    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 sinceJanuary 1, 1970) we will use the dateadd function to format a readable date. Since this is GMT, youwill need to provide an offset according to your local time zone. The calling object provides the variableUNIX_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 valuesin the database tables (i.e., as integers instead of character strings). It is necessary to provide some typeof conversion so meaningful reports can be generated. It should be noted for each selection type fieldyou place on a report or form, you will need to use some similar type of conversion. Again, as in thedate/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

  • 8/10/2019 MS Access Integration Note

    14/14

    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 ensurethat 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 othertrademarks 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.docPN: AXA-IN-41-0198


Recommended