|
Function SendString (StringVar$)
' The Wedge
must be running and activated for COM1 for this code to work
chan = DDEInitiate("WinWedge", "Com1") '
initiate DDE channel with wedge
DDEExecute chan, "[SEND(" + StringVar$ + ")]"
' send String out the serial port
DDETerminate chan ' terminate the link
End Function
This code can even be used to send an entire table or query out
the serial port:
Sub SendQuery()
Dim chan, MyDb, MyQuery, strSend
'set database
Set MyDb = CurrentDb()
'open a
table or query that holds the data you wish to send
Set MyQuery = MyDb.OpenRecordset("Deliveries")
'Open DDE
Channel to WinWedge
chan = DDEInitiate("WinWedge", "COM2")
'point
to first record in the table/query
MyQuery.MoveFirst
Do
strSend = "" 'reset string between
records
'Generate string to send
For i = 0 To MyQuery.Fields.Count - 1
strSend = strSend & MyQuery.Fields(i) & ","
Next
'trim off last comma and replace it with CR/LF
strSend = Left(strSend, Len(strSend) - 1) & vbCrLf
'send string
DDEExecute chan, "[SEND(" + strSend + ")]"
MyQuery.MoveNext 'point to next record in
the query
Loop Until MyQuery.EOF 'while (we have not
reached the end of the table/query)
quit:
'close DDE channel and clean up
DDETerminate chan
Set db = Nothing
Set chan = Nothing
End Sub

Collecting Data Directly To A Table In
An Access Database
Launching And Terminating WinWedge From
Access
|