TALtech Logo
search
Products Support Resources Free Software
  TALtech Home:  Support:  WinWedge Support:  DDE and the WinWedge:  DDE Examples for Access:


Collecting Data Directly into a Form in an Access Database

 

Steps for setting up the WinWedge:

1. Select "DDE Server" from the "Mode" menu in the Wedge. When the dialog box appears asking for a DDE Command Destination Application, enter: "MSACCESS" as the Application Name and the name of your open database (without the MDB Extension) as the DDE topic.

2. Select "Input Record Structure" in the "Define" menu and define the structure of the input data to WinWedge. When you get to the final Window entitled "Input Record Definition Editor", enter the string: [GrabData] as the Field Postamble DDE Command after the last data field that you have defined. This is a DDE command that will be sent to MSACCESS after each data record is received by the Wedge.

3. Set up the rest of the Wedge as needed for your serial device and then activate it.

 

Steps for setting up MS ACCESS:

MSAccess does not have a "GrabData" DDE command so the first step is to create one. When you define a macro in an Access database, the name of the macro automatically becomes a valid MSAccess DDE command for as long as the database is open.

1. Create a new macro that performs the "RunCode" Action. For the function name that is required by the RunCode action, enter the name "GetWedgeData()". Save the macro with the macro name "GrabData" and finally, create a new module with a function named "GetWedgeData()" and enter the following commands in the body of the function:

Function GetWedgeData ()

' Declare variables
Dim ChannelNumber, MyData As Variant

' open a link to WinWedge
ChannelNumber = DDEInitiate("WinWedge", "Com1")
' get data from field(1)
MyData = DDERequest(ChannelNumber, "FIELD(1)")
' terminate the link
DDETerminate ChannelNumber
' if no data then quit
If Len(MyData) = 0 Then Exit Function

'Data from Field(1) in WinWedge is now in the variable "MyData". The following code sets the value of Textbox1 on Form1 to display the current WinWedge data.

Forms!Form1!Textbox1.SetFocus
Forms!Form1!Textbox1.Text = MyData

End Function

The example above sets up the Wedge to issue a DDE command consisting of the name of an Access macro (directly to the Access database that contains the macro) after each data record is received from your serial device. The macro calls an Access VBA function that performs a DDERequest back to the Wedge and returns the contents of FIELD(1) to a variable named "MyData". It then updates Form1 with the data.

See Also:
Launching And Terminating WinWedge From Access
Collecting Data Directly into a Table in an Access Database
Transmitting Variables Out The Serial Port From Access

Back to Top

TALtech Home  |  Products  |  Resources  |  Free Software  |  Support  |  Buy Now  |  Register Your Products  | 
Site Map  |  Contact TALtech  |  News