On Click Error

A

AHopper

I have a database is split front end MDE and back end
MDB. The workstations are using Access Runtime.
In the On Click Event of a command button on a form I
have the following. The code Functions referred to are
at the end and are located in a Public module. When the
code is finished I get the following error message:

When I use this on the computer were development is
taking place ( MDB and full version of Access) I do not
get an error and everything works as it should, but when
I try to use it on the workstations (MDE and Access
Runtime) I get the following message at the end of the
code.

The expression On Click you entered as the event property
setting produced the following error: Invalid procedure
call or argument.

* The expression may not result in the name of a macro,
the name of a user-defined function, or [event procedure].
* There may have been an error evaluating the
function, event, or macro.

Thank you in advance for your help

Allan


Private Sub OpenPackagingForm_Click()
On Error GoTo Err_OpenPackagingForm_Click

Dim X As Date
Answer = MsgBox("Are you using ""Mettler Toledo Digitol""
scale?", vbYesNo + vbQuestion)
If Answer = vbYes Then
On Error GoTo ErrorHandlerOne
KillWedge
X = Now + 0.00002
Do While Now < X
DoEvents ' allow other Windows processes to continue
Loop
LaunchDigitolScaleWedge
DoCmd.OpenForm "OnePGoodPackForm", acNormal
Me.Visible = False
Exit Sub
ErrorHandlerOne:
LaunchDigitolScaleWedge
DoCmd.OpenForm "OnePGoodPackForm", acNormal
Me.Visible = False
Exit Sub
End If
If Answer = vbNo Then
Answer = MsgBox("Are you using ""Mettler Toledo Spider""
scale?", vbYesNo + vbQuestion)
If Answer = vbYes Then
On Error GoTo ErrorHandlerTwo
KillWedge
X = Now + 0.00002
Do While Now < X
DoEvents ' allow other Windows processes to continue
Loop
LaunchSpiderScaleWedge
DoCmd.OpenForm "OnePGoodPackForm", acNormal
Me.Visible = False
Exit Sub
ErrorHandlerTwo:
LaunchSpiderScaleWedge
DoCmd.OpenForm "OnePGoodPackForm", acNormal
Me.Visible = False
Exit Sub
End If
If Answer = vbNo Then
Answer = MsgBox("Are you using ""Sartorius"" scale?",
vbYesNo + vbQuestion)
If Answer = vbYes Then
On Error GoTo ErrorHandlerThree
KillWedge
X = Now + 0.00002
Do While Now < X
DoEvents ' allow other Windows processes to continue
Loop
LaunchSartoriusScaleWedge
DoCmd.OpenForm "OnePGoodPackForm", acNormal
Me.Visible = False
Exit Sub
ErrorHandlerThree:
LaunchSartoriusScaleWedge
DoCmd.OpenForm "OnePGoodPackForm", acNormal
Me.Visible = False
Exit Sub
End If
If Answer = vbNo Then
On Error GoTo ErrorHandlerFour
KillWedge
X = Now + 0.00002
Do While Now < X
DoEvents ' allow other Windows processes to continue
Loop
ErrorHandlerFour:
DoCmd.OpenForm "OnePGoodPackForm", acNormal
Me.Visible = False
End If
End If
End If

Exit_OpenPackagingForm_Click:
Exit Sub

Err_OpenPackagingForm_Click:
MsgBox Err.Description
Resume Exit_OpenPackagingForm_Click

IN MODULE - Public
The above code points to a module that contains the
following. Only the code of "LaunchDigitolScaleWedge()".
The code for "LaunchSpiderScaleWedge"
and "LaunchSartoriusScaleWedge"



Function KillWedge() ' This function unloads the Wedge
from memory
Dim Chan As String
' initiate DDE channel with wedge on COM1
Chan = DDEInitiate("WinWedge", "Com1")

' send AppExit command to Wedge
DDEExecute Chan, "[AppExit]"

' close the DDE Channel
DDETerminate Chan

End Function


Function LaunchDigitolScaleWedge()
Dim CmdLine As String
Dim RetVal As String
Dim X As Date
' This function will launch the Wedge feeding it the
' name of a configuration file on the command line
' causing the Wedge to automatically load the config
' file and activate itself

CmdLine = "C:\winwedge\winwedge.exe
C:\winwedge\DigitolScaleWedgeDDE.SW3"

RetVal = Shell(CmdLine)

' wait for roughly 2 seconds
' give wedge time to load and activate itself

X = Now + 0.00002
Do While Now < X
DoEvents ' allow other Windows processes to continue
Loop

' set the focus back to Access
AppActivate "Microsoft Access"

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top