This paper describes how to integrate your Satellite Forms 4.0 EE application with corporate data stored in Microsoft Access 97. Although the steps described here take advantage of some specific features of Access, many of the concepts are general and apply to other database management systems as well.
Satellite Forms has the ability to save your linked files in DBF or MDB files. If you wish to use Access 97, you must use the DBF format. Access 97 has the ability to link to dBase 5 DBF files regardless of the version of the Microsoft Data Access Components (MDAC) installed on the computer. However, installing MDAC 2.1 or greater can break some of the connections of DBF files to other database management systems, including Access 2000.
Access 2000 installs MDAC 2.5 on the host computer, and Windows 2000 comes installed with MDAC 2.5. Access 2000 cannot link and read/write to DBF files, unless you upgrade the host computer to MDAC 2.6 and also install the Jet ServicePack 4. If you wish to use Access 2000, you should save your files in MDB format.
If you use Access 97, and then later change to Access 2000, you must rewrite your program to accommodate the file format, or upgrade your host computer, as noted above. For this reason, it is often better to use the Access 2000 format unless you have a compelling reason to do otherwise.
If you find any errors in this tutorial, please contact me at jon@pocketinformatics.com .
Jon Blackman, M.D., M.S.
Updated 9/9/01
Please refer to the Satellite Forms Developers Guide, Using Satellite Forms with Microsoft Access, for a description of this process.
Please refer to the Satellite Forms Developers Guide, Using Satellite Forms with Microsoft Access, for a description of this process.
1. Name: WRKITEMID
2. Data Type: Numeric
3. Width 4
Access 97 can read linked dBase 5 intermediate tables as if they were native Access tables. Linking the Satellite Forms intermediate tables to Access makes it easier to view the data in these tables directly from within Access.

Importing the Satellite Forms API ensures that Access will successfully execute the code that you write to mange the HotSync operations. The API sets up several constraints and parameters that will be used by your code. For Access users, an Access Add-in named SATFORMS.MDA is in the \Include directory of the Satellite Forms installation.

You now need to create three additional tables in Access to represent the corporate database. These tables should have the same structure as the dBase 5 tables created by Satellite Forms for shared data elements. However, the overall structure of the tables might differ, depending upon your needs. Some data, for example, might be specific to workers at corporate headquarters, and passing this data to workers in the field would be unnecessary. In our example, we will create identical corporate tables.

For the HotSync operation to correctly transfer data between Access and Satellite forms, your Access server application must be running when the HotSync occurs and the Active X control must be active (key point). The easiest way to do this is to build an Access form with the Active X control on it as part of the application, and have this form open (running) on the server PC (the PC to which the users HotSync).

The following steps describe the code that you will write to manage the HotSync operation. Before we start moving the data, we must do some setup by declaring and setting a number of variables and creating a Form_Load subroutine.
In Access, click the Forms tab, and on the View menu select Code. Add the following Constants and Dim statements under General Declarations (Option Compare Database will already be there). These new variables will be used to store the file locations of the intermediate tables and track the progress of the HotSync operation.
Option
Compare Database
Option
Explicit
Const
Status_HotSyncStart = 1
Const
Status_HotSyncCommandComplete = 3
Const
Status_HotSyncEnd = 2
Dim
strWRKLOOKU As String
Dim
strWRKSITES As String
Dim strWRKWORKI
As String
Dim
HotSync_Progress As String
Dim CmdCount
As Integer
Dim strPATH
As String
Dim strSDDI
As String
Dim
strCreatorID As String
Add a new procedure called Form_Load.
Go to InsertฎProcedure..... Enter the following and press OK.
Add the following code to your procedure. It will disable notifications from Access about changing data, set the path to your project directory, set string names for the variables, and enable the Satellite Forms ActiveX control.
Private Sub
Form_Load()
'Disable warnings
DoCmd.SetWarnings 0
'Path to project directory
strPATH = "c:\Program Files\Satellite
Forms EE\Projects
\Sample Projects\Work Order 97\"
'String name of SDDI DLL
strSDDI = "Sddi_PalmDB.dll"
'Creator ID in the App Designer
'You will change this when you distribute
your application
strCreatorID = "SMSF"
strWRKLOOKU = strPATH &
"WRKLOOKU.dbf"
strWRKSITES = strPATH &
"WRKSITES.dbf"
strWRKWORKI = strPATH &
"WRKWORKI.dbf"
HotSync_Progress = "Begin"
SatForms.Enabled = True
End Sub
You will now write the code that will move the data from handheld devices to the corporate database and from the corporate database back to handheld devices. As described earlier, there are four data transfers that we need to perform in our sample application. Your code will vary to fit your needs.
A to B: Updated records move from handheld devices to dBase 5 intermediate tables.
B to C: Updated records move from dBase 5 intermediate tables to Access database.
C to B: New records move from Access database to dBase 5 intermediate tables.
B to A: New records move from dBase 5 intermediate tables to handheld devices.
We will look at each of these steps in detail, working with the wrkSites table.
You will create the subroutine SatForms_HotSyncStatus, which will serve as your HotSync event handler. To move data from the handheld device to the dBase 5 intermediate tables, you will use the GetTableFromPalmPilot method of the Satellite Forms ActiveX control. To transfer multiple tables, you can call this method more than once using different filenames. The variable CmdCount is used to keep track of how many tables are transferred (or commands have been given).
Important: In order to execute your new code, you must open the frmWrkSites form.
Verify that data is being transferred by making changes to the data on your handheld then synchronizing it back to Access. The GetTableFromPalmPilot method will overwrite all existing data in the tables with data from the handheld.
The Form_Load Subroutine is listed below. In the following sections, we will explain the logic and fill in the code.
Private Sub
SatForms_HotSyncStatus(ByVal StatusCode As Long, ByVal Param As Long)
'Check to
make sure events are from this application
If
SatForms.CreatorString <> strCreatorID Then Exit Sub
If StatusCode
= Status_HotSyncEnd Then
'We're done
HotSync_Progress = "End"
Exit Sub
End If
If StatusCode
= Status_HotSyncStart Then
'Move data from A --> B
Call
SatForms.GetTableFromPalmPilot(strWRKWORKI, strCreatorID, strSDDI, 0, 1, 0)
Call
SatForms.GetTableFromPalmPilot(strWRKSITES, strCreatorID, strSDDI, 0, 1, 0)
'Count 2 commands to transfer files
CmdCount = 2
HotSync_Progress = "A>B"
End If
If StatusCode
= Status_HotSyncCommandComplete Then
CmdCount = CmdCount - 1
If CmdCount <> 0 Then GoTo
CmdCompleteExit
'File set not yet finished
If HotSync_Progress = "A>B"
Then
'Move data from B --> C
HotSync_Progress = "B>C"
End If
If HotSync_Progress = "B>C"
Then
'Move Data from C --> B
HotSync_Progress = "C>B"
End If
If HotSync_Progress = "C>B"
Then
'Move data from B --> A
HotSync_Progress = "B>A"
Exit Sub
End If
CmdCompleteExit:
End If
End Sub
Important: Be sure that your application completes the movement of data from A to B before it tries to move this data from B to C.
Use the Access Update Query command to move data from the dBase 5 intermediate tables (linked to Access) to the corporate database.
Please refer to the Satellite Forms Developers Guide, Using Satellite Forms with Microsoft Access, for a description of this process. The example updates the WRKSITES_CORPORATE table. If you modified the wrkWorkItems table in App Designer earlier in the tutorial, you may use the same process to update the WRKWORKI_CORPORATE table.

Now you will need to add additional code to your HotSync handler to run this query. The code should execute after the methods GetTableFromPalmPilot have completed. Use the status code HotSyncCommandComplete and CmdCount to determine when this occurs.
The HotSyncCommandComplete event occurs once for every command given, or file transferred. In this case, there were two commands to upload files, so this event will occur twice before both tables are uploaded. Decrement CmdCount each time the Status_HotSyncCommandComplete fires. When CmdCount has decremented to zero, all the commands have completed (or files uploaded) and it is time to process the data.
Add the following code to your event handler and test your program. Make changes on the handheld and perform a HotSync. Changes on the Palm should be reflected on your *_CORPORATE table.
If HotSync_Progress = "A>B" Then
'Move data from B --> C
DoCmd.OpenQuery ("UPDATE_WRKSITES_CORPORATE")
DoCmd.OpenQuery ("UPDATE_WRKWORKI_CORPORATE")
HotSync_Progress = "B>C"
End If
Use the Access Append Query command to add new records from the corporate database to the dBase 5 intermediate tables linked to Access.
Please refer to the Satellite Forms Developers Guide, Using Satellite Forms with Microsoft Access, for a description of this process. The example appends records to the WRKSITES table. If you modified the wrkWorkItems table in App Designer earlier in the tutorial, you may use the same process to append records to the WRKWORKI table.
Test your queries by adding some records to the corporate tables, double-clicking the queries, and checking the linked tables. Be sure to add new and unique ID numbers to the new records. You may want to automate this process in your application.

As before, add the following code and test your data transfer.
If HotSync_Progress = "B>C" Then
'Move
Data from C --> B
DoCmd.OpenQuery ("INSERT_WRKSITES")
DoCmd.OpenQuery ("INSERT_WRKWORKI")
HotSync_Progress = "C>B"
End If
The last step is moving the dBase 5 data back to handheld devices. Add the following code to your HotSync event handler to run the CopyTableToPalmPilot methods. This will take the data from the dBase 5 intermediate tables and move it to the handheld.
If HotSync_Progress = "C>B" Then
'Move
data from B --> A
Call
SatForms.CopyTableToPalmPilot(strWRKWORKI, strCreatorID, strSDDI, 0, 1, 0)
Call SatForms.CopyTableToPalmPilot(strWRKSITES, strCreatorID, strSDDI, 0, 1, 0)
Call
SatForms.CopyTableToPalmPilot(strWRKLOOKU, strCreatorID, strSDDI, 0, 1, 0)
'Count 3 commands to transfer files
CmdCount = 3
HotSync_Progress = "B>A"
Exit
Sub
End If
Test your procedures to see that records are moved appropriately.
The final code is as follows: (Note that longer lines wrap to the next line.)
Option Compare Database
Option Explicit
Const Status_HotSyncStart = 1
Const Status_HotSyncCommandComplete = 3
Const Status_HotSyncEnd = 2
Dim strWRKLOOKU As String
Dim strWRKSITES As String
Dim strWRKWORKI As String
Dim HotSync_Progress As String
Dim CmdCount As Integer
Dim strPATH As String
Dim strSDDI As String
Dim strCreatorID As String
Private Sub Form_Load()
'Disable
warnings
DoCmd.SetWarnings 0
'Path to
project directory
strPATH =
"c:\Program Files\Satellite Forms EE\Projects\Sample Projects\Work Order
97\"
'String
name of SDDI DLL
strSDDI =
"Sddi_PalmDB.dll"
'Creator
ID in the App Designer
'You will
change this when you distribute your application
strCreatorID = "SMSF"
strWRKLOOKU = strPATH & "WRKLOOKU.dbf"
strWRKSITES = strPATH & "WRKSITES.dbf"
strWRKWORKI = strPATH & "WRKWORKI.dbf"
HotSync_Progress = "Begin"
SatForms.Enabled = True
End Sub
Private Sub SatForms_HotSyncStatus(ByVal StatusCode
As Long, ByVal Param As Long)
'Check to make sure events are from this application
If SatForms.CreatorString <> strCreatorID Then
Exit Sub
If StatusCode = Status_HotSyncEnd Then
'We're
done
HotSync_Progress = "End"
Exit Sub
End If
If StatusCode = Status_HotSyncStart Then
'Move
data from A --> B
Call
SatForms.GetTableFromPalmPilot(strWRKWORKI, strCreatorID, strSDDI, 0, 1, 0)
Call
SatForms.GetTableFromPalmPilot(strWRKSITES, strCreatorID, strSDDI, 0, 1, 0)
'Count 2
commands to transfer files
CmdCount
= 2
HotSync_Progress = "A>B"
End If
If StatusCode = Status_HotSyncCommandComplete Then
CmdCount
= CmdCount - 1
If
CmdCount <> 0 Then GoTo CmdCompleteExit
'File set
not yet finished
If
HotSync_Progress = "A>B" Then
'Move
data from B --> C
DoCmd.OpenQuery ("UPDATE_WRKSITES_CORPORATE")
DoCmd.OpenQuery ("UPDATE_WRKWORKI_CORPORATE")
HotSync_Progress = "B>C"
End If
If
HotSync_Progress = "B>C" Then
'Move
Data from C --> B
DoCmd.OpenQuery
("INSERT_WRKSITES")
DoCmd.OpenQuery ("INSERT_WRKWORKI")
HotSync_Progress = "C>B"
End If
If
HotSync_Progress = "C>B" Then
'Move
data from B --> A
Call
SatForms.CopyTableToPalmPilot(strWRKWORKI, strCreatorID, strSDDI, 0, 1, 0)
Call
SatForms.CopyTableToPalmPilot(strWRKSITES, strCreatorID, strSDDI, 0, 1, 0)
Call
SatForms.CopyTableToPalmPilot(strWRKLOOKU, strCreatorID, strSDDI, 0, 1, 0)
'Count 3 commands to transfer files
CmdCount = 3
HotSync_Progress = "B>A"
Exit
Sub
End If
CmdCompleteExit:
End If
End Sub