Option Compare Database

Function haAutoEntry()
On Error Resume Next
Dim haWin32, haScript As Object
Dim strInput As String

'create objects open HyperACCESS
Set haWin32 = CreateObject("HAWin32")
Set haScript = haWin32.haInitialize("accessAutoEntry")

'connect HyperACCESS
haScript.haSizeHyperACCESS 3
haScript.haOpenSession "session.HAW"
haScript.haConnectSession 0
haScript.haWaitForConnection 1, 100000

'loop while connected
While haScript.haGetConnectionStatus = 1
strInput = haScript.haGetInput(0, -1, 50, 1000)
If strInput <> "" Then
'clean up and parse data
strInput = Replace(Replace(strInput, Chr(10), ""), Chr(13), "")
Data = Split(strInput, ",")
strDate = Data(0)
strVal1 = Data(1)
strVal2 = Data(2)

strValues = "('" & strDate & "', '" & strVal1 & "', '" & strVal2 & "')"
strSql = "INSERT INTO myTable ( datestamp, Val1, Val2 ) VALUES " & strValues

DoCmd.SetWarnings False
DoCmd.RunSQL strSql
DoCmd.SetWarnings True
End If
strInput = ""
DoEvents
Wend

haScript.haTerminate

End Function

Function haDisconnect()
Set haWin32 = GetObject(, "HAWin32")
Set haScript = haWin32.haInitialize("disconnect")
haScript.haDisconnectSession
haScript.haTerminate

End Function

To execute this sample save the above functions in a Visual Basic module in your Microsoft Access database. Run the haAutoEntry function to start capturing data, run the haDisconnect function to stop capturing data.

Return to sample script index

Hilgraeve