DDE Between Access ADP and B-Coder Pro not working in win2k

From: Ron Lounsbury (rlounsbury@123ProgenyNO.SPAMnet)
Date: 12/16/02


From: "Ron Lounsbury" <rlounsbury@123ProgenyNO.SPAMnet>
Date: Mon, 16 Dec 2002 16:23:05 -0500


We have a project that is currently running under NT4/SP6a. The project is
mainly a SQL back end with a web front end. A major part of this project
includes printing barcodes which are to be applied on equipment that our
software tracks. The barcode printing is done via an Access ADP file which
is installed to run as a service under NT using the srvany program (see MS
KB 137890). The ADP generates barcodes by passing the string to be made
into a barcode to a program called B-Coder Pro (ver 3) via DDE calls.

All of this works fine under winNT, but we are now in the process of trying
to upgrade to win2k. What we have found is that if we run the ADP directly
from the desktop, everything works fine, but if we try to run the ADP as a
service, the barcodes fail. It appears that either the shell command to
start bcoder doesn't run, or the copy/paste via DDE to bcoder doesn't work.
We are unable to determine which it is. From the beeps we get when we try
to send a barcode, we are fairly sure that the problem is somewhere in the
DDE calls. I have included the relevant VBA code from Access below.

Can anyone suggest what the problem here is? All suggestions gratefully
accepted!

TIA
Ron Lounsbury

'*********************** VBA Code
**********************************************
Function BarCodeTbl(MyTextField As String, MyPictureField As String, _
                    MyTable As String, RecordCT As Long, Config As String)
As Long
On Error Resume Next

Dim strconfig As String, BCDirectory As String, chan As Long, i As Boolean
Dim total As Long, x As Long, xtim As Date, errposit As String

' check to see if B-coder is active; if not resume and attempt to open it
via a shell commsnd
' wait 5 seconds and then abort if the channel to it is not active

BarCodeTbl = 0
BCDirectory = "C:\B-CODER3"
errposit = "firstload of BCODER"
chan = DDEInitiate("B-Coder", "System")

If Err Then
    Err = 0

    i = Shell(BCDirectory + "\b-coder", 7)
    xtim = Now + TimeValue("00:00:05")
    Do While Now < xtim
        DoEvents
    Loop
    errposit = "nextload of BCODER"

    If Err Then Exit Function

    chan = DDEInitiate("B-Coder", "System")

End If

' Bcoder initiated
Debug.Print "BCoder initiated"
On Error GoTo BarCode_error
errposit = "set BCODER params"
DDEExecute chan, "[MESSAGEWARNINGS=OFF]"
DDEExecute chan, "[PRINTWARNINGS=OFF]"
DDEExecute chan, "[QUIETZONES=ON]"
DDEExecute chan, "[APPMINIMIZE]"

strconfig = "[OPENCONFIG(" & BCDirectory & "\" & Config & ")]"
errposit = "load BCODER config"

DDEExecute chan, strconfig
errposit = "open BCone TBL"

DoCmd.OpenTable MyTable, acViewNormal

DDEExecute chan, "[FONTSCALING=OFF]"
DDEExecute chan, "[FONTBOLD]"
errposit = "move to first BCone TBLrecord"
DoCmd.GoToRecord acDataTable, MyTable, acFirst

For x = 1 To RecordCT

    DoCmd.GoToControl "TobeCoded2D"
    DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_COPY, , A_MENU_VER20
    DDEExecute chan, "[PASTE]"

    DDEExecute chan, "[BUILD/COPY]"

    DoCmd.GoToControl "BClabel2D"
    DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_PASTE, , A_MENU_VER20

    Debug.Print x, " labelsgenerated"
    BarCodeTbl = x
    errposit = "move to " & Str(x) & "-th BCone TBLrecord"

    If x < RecordCT Then DoCmd.GoToRecord acTable, MyTable, A_NEXT

Next

BarCode_exit:
    On Error Resume Next
    DoCmd.Close acTable, MyTable
    DDEExecute chan, "[appexit]"
    DDETerminate chan

    Exit Function

BarCode_error:
    Forms("frmStartUp")!msgerr = Forms("frmStartUp")!msgerr & "BC/
BarCodeTbl function error: " _
                                & Err.Description & "(" & errposit & ")" &
vbCrLf
    Resume BarCode_exit

End Function


Quantcast