MDE Problem

AndyShuter

Registered User.
Local time
Today, 23:21
Joined
Mar 3, 2003
Messages
151
I dont know if anyone can help with this but here goes.

We recently developed an API that sends faxes via an "eFaxing" service. The service works fine as an mdb, but when we compile to an mde we get the following error....

"The Expression On Click as the event property setting produced the following error....

"The command isnt available in an MDE / ADE database"

Problem is, we cant debug as it works OK in an mdb

Any suggestions pls?

btw - I'll post the function in the next post......
 
my function

Option Compare Database

Public Fax As String
Public FaxUser As String
Public FaxPwd As String

Public Function SendFax(RptName As String, FaxNo As String, Optional strLinkCriteria As String = "") As Long
If UCase(Fax) = "INTERFAX" Then
If FaxUser = "" Or FaxPwd = "" Then
MsgBox "Fax username and/or password missing from dealtrak configuration", "", "DealTrak"
Exit Function
End If

If Not strLinkCriteria = "" Then
DoCmd.OpenReport RptName, acViewDesign
reports(RptName).FilterOn = True
reports(RptName).Filter = strLinkCriteria
End If

Dim tmpRpt As String
tmpRpt = "c:\dealtrak\tmp_" & Format(Now, "yyyymmddhhnnss") & ".snp"
DoCmd.OutputTo acOutputReport, RptName, acFormatSNP, tmpRpt

' Load snapshot as base64binary
Dim img() As Byte
Open tmpRpt For Binary Access Read Lock Read As #1
ReDim img(LOF(1) - 1) 'Keep enough space to read the entire file to memory
Get #1, , img
Close #1

If Not strLinkCriteria = "" Then DoCmd.Close acReport, RptName, acSaveNo
Kill tmpRpt

Dim Success As Double
Dim interfax As New clsws_InterFax
Success = interfax.wsm_Sendfax(FaxUser, FaxPwd, ConvertPhoneIntFormat(FaxNo), img, "SNP")
If Success > 0 Then

MsgBox "Fax sent successfully.", , "DealTrak"

Dim Method As String
Method = "Interfax"
MySQL_Query "INSERT into tblSMSLog SET" & _
" Message = " & MyData(Method) & _
",SentTo = " & MyData(FaxNo) & _
",DateSent = Now()"
Else
MsgBox "Fax not sent. Fax service error code: " & InterFaxErrorCodes(CInt(Success)), , "DealTrak"
End If
SendFax = CLng(Success)
Else
Dim objWFSend As New WFSendClass
Dim lngReturn As Long, strFaxError As String
Dim FinanceFaxNo As String
With objWFSend
.HoldFax = False
.FaxReport RptName
.FaxDial FaxNo
.FaxRecipient "", ""
lngReturn = .SendFax(True, , True) 'Delete the fax event after send
If lngReturn <> True Then
strFaxError = .TranslateFaxError(lngReturn)
Debug.Print strFaxError
End If
End With
Set objWFSend = Nothing
SendFax = 0
End If


End Function

Function FaxQuery(Optional ShowActiveOnly As Boolean = False, Optional Show As Integer = 50) As struct_FaxItemEx()
Dim FaxItems() As struct_FaxItemEx
Dim interfax As New clsws_InterFax
Dim ResultCode As Long
If ShowActiveOnly Then
FaxItems = interfax.wsm_FaxQuery(FaxUser, FaxPwd, "ACTIVE", "", -1, ResultCode)
Else
FaxItems = interfax.wsm_FaxQuery(FaxUser, FaxPwd, "GT", "0", Show, ResultCode)
End If
If ResultCode < 0 Then
MsgBox "Fax service error code: " & InterFaxErrorCodes(CInt(ResultCode)), , "DealTrak"
End If
FaxQuery = FaxItems
End Function

Function ReSendFax(FaxID As String, FaxNumber As String) As Long
Dim Success As Double
Dim interfax As New clsws_InterFax
Success = interfax.wsm_ReSendFax(FaxUser, FaxPwd, FaxID, FaxNumber)
If Success > 0 Then
MsgBox "Fax ReSent successfully.", , "DealTrak"
Else
MsgBox "Fax not ReSent. Fax service error code: " & InterFaxErrorCodes(CInt(Success)), , "DealTrak"
End If
ReSendFax = CLng(Success)
End Function

Function InterFaxErrorCodes(ErrorCode As Integer) As String
Select Case (ErrorCode)
Case -112
InterFaxErrorCodes = "No valid recipients added or missing fax number"
Case -123
InterFaxErrorCodes = "No valid documents attached"
Case -150
InterFaxErrorCodes = "Internal System Error"
Case -1002
InterFaxErrorCodes = "Number of types does not match number of document sizes string"
Case -1003
InterFaxErrorCodes = "Authentication error"
Case -1004
InterFaxErrorCodes = "Missing file type"
Case -1005
InterFaxErrorCodes = "Transaction does not exist"
Case -1007
InterFaxErrorCodes = "Size value is not numeric or not greater than 0"
Case -1008
InterFaxErrorCodes = "Total sizes does not match filesdata length"
Case -1009
InterFaxErrorCodes = "Image not available (may happen if the 'delete fax after completion' feature is active)"
Case -1030
InterFaxErrorCodes = "Invalid Verb or VerbData"
Case -3001
InterFaxErrorCodes = "Invalid MessageID"
Case -3002
InterFaxErrorCodes = "From parameter is larger than image size"
Case -3003
InterFaxErrorCodes = "Image doesn't exist"
Case -3004
InterFaxErrorCodes = "TIFF File Is Empty"
Case -3005
InterFaxErrorCodes = "Chunk size is smaller than 1"
Case -3006
InterFaxErrorCodes = "Max item is smaller than 1"
Case -3007
InterFaxErrorCodes = "No permission for this action (In inbound method GetList, LType is set to AccountAllMessages or AccountNewMessages, when the username is not a Primary user)"
Case Else
InterFaxErrorCodes = "Unknown Error"
End Select
End Function

Function FaxStatusCodes(StatusCode As Integer) As String
Select Case StatusCode
Case -1
FaxStatusCodes = "Rendering"
Case -2
FaxStatusCodes = "In-Queue"
Case -3
FaxStatusCodes = "Sending"
Case -22
FaxStatusCodes = "On Hold"
Case 0
FaxStatusCodes = "Sent"
Case 3072
FaxStatusCodes = "Error"
Case 3224
FaxStatusCodes = "No Response"
Case 3912
FaxStatusCodes = "No Tone"
Case 3931
FaxStatusCodes = "Busy"
Case 3935
FaxStatusCodes = "No Answer"
Case 3936
FaxStatusCodes = "Voice Answer"
Case 3937
FaxStatusCodes = "Rings Busy"
Case 6017
FaxStatusCodes = "Busy"
Case 6018
FaxStatusCodes = "No Answer"
Case 8021
FaxStatusCodes = "No Answer"
Case 8025
FaxStatusCodes = "Busy"
Case Else
FaxStatusCodes = "Error"
End Select
End Function
 
If you wrap your code in the code tags by pressing the Octothorp "#", it will preserve the indentations. I see an EXTRA else in the code.
Code:
If Success > 0 Then

   MsgBox "Fax sent successfully.", , "DealTrak"

   Dim Method As String
   Method = "Interfax"
   MySQL_Query "INSERT into tblSMSLog SET" & _
   " Message = " & MyData(Method) & _
   ",SentTo = " & MyData(FaxNo) & _
   ",DateSent = Now()"
Else
   MsgBox "Fax not sent. Fax service error code: " & InterFaxErrorCodes(CInt(Success)), , "DealTrak"
End If
SendFax = CLng(Success)
[COLOR="Red"][B]Else '<--- EXTRA???[/B][/COLOR]
Dim objWFSend As New WFSendClass
Dim lngReturn As Long, strFaxError As String
Dim FinanceFaxNo As String
With objWFSend
...or am I just seeing things???
 
Try going to the VBE IDE window and go to Debug > Compile and see what errors come up and get highlighted as you can't create an MDE file if there are compile errors. If you know which line it is that gets highlighted, it would probably help you (or us) know why it won't compile.
 
The code compiles fine, the mde runs and works as it normally should (apart from this module!) The whole thing works OK as an mdb.

Puzzler
 
Try adding the Red Code to the top of your module and compiling again.
Code:
Option Compare Database
[COLOR="Red"][B]Option Explicit[/B][/COLOR]
As I see it, your code should *not* compile without throwing an error. What If does that else I highlighted belong to?
 
Thanks Andy. I really didn't see it. :o
Code:
Option Compare Database

Public Fax As String
Public FaxUser As String
Public FaxPwd As String

Public Function SendFax(RptName As String, FaxNo As String, Optional strLinkCriteria As String = "") As Long
   If UCase(Fax) = "INTERFAX" Then
      If FaxUser = "" Or FaxPwd = "" Then
         MsgBox "Fax username and/or password missing from dealtrak configuration", "", "DealTrak"
         Exit Function
      End If

      If Not strLinkCriteria = "" Then
         DoCmd.OpenReport RptName, acViewDesign
         Reports(RptName).FilterOn = True
         Reports(RptName).Filter = strLinkCriteria
      End If

      Dim tmpRpt As String
      tmpRpt = "c:\dealtrak\tmp_" & Format(Now, "yyyymmddhhnnss") & ".snp"
      DoCmd.OutputTo acOutputReport, RptName, acFormatSNP, tmpRpt

      ' Load snapshot as base64binary
      Dim img() As Byte
      Open tmpRpt For Binary Access Read Lock Read As #1
      ReDim img(LOF(1) - 1)   'Keep enough space to read the entire file to memory
      Get #1, , img
      Close #1

      If Not strLinkCriteria = "" Then DoCmd.Close acReport, RptName, acSaveNo
      Kill tmpRpt

      Dim Success As Double
      Dim interfax As New clsws_InterFax
      Success = interfax.wsm_Sendfax(FaxUser, FaxPwd, ConvertPhoneIntFormat(FaxNo), img, "SNP")
      If Success > 0 Then

         MsgBox "Fax sent successfully.", , "DealTrak"

         Dim Method As String
         Method = "Interfax"
         MySQL_Query "INSERT into tblSMSLog SET" & _
                     " Message = " & MyData(Method) & _
                     ",SentTo = " & MyData(FaxNo) & _
                     ",DateSent = Now()"
      Else
         MsgBox "Fax not sent. Fax service error code: " & InterFaxErrorCodes(CInt(Success)), , "DealTrak"
      End If
      SendFax = CLng(Success)
   Else
      Dim objWFSend As New WFSendClass
      Dim lngReturn As Long, strFaxError As String
      Dim FinanceFaxNo As String
      With objWFSend
         .HoldFax = False
         .FaxReport RptName
         .FaxDial FaxNo
         .FaxRecipient "", ""
         lngReturn = .SendFax(True, , True)   'Delete the fax event after send
         If lngReturn <> True Then
            strFaxError = .TranslateFaxError(lngReturn)
            Debug.Print strFaxError
         End If
      End With
      Set objWFSend = Nothing
      SendFax = 0
   End If
End Function

Function FaxQuery(Optional ShowActiveOnly As Boolean = False, Optional Show As Integer = 50) As struct_FaxItemEx()
   Dim FaxItems() As struct_FaxItemEx
   Dim interfax As New clsws_InterFax
   Dim ResultCode As Long
   If ShowActiveOnly Then
      FaxItems = interfax.wsm_FaxQuery(FaxUser, FaxPwd, "ACTIVE", "", -1, ResultCode)
   Else
      FaxItems = interfax.wsm_FaxQuery(FaxUser, FaxPwd, "GT", "0", Show, ResultCode)
   End If
   If ResultCode < 0 Then
      MsgBox "Fax service error code: " & InterFaxErrorCodes(CInt(ResultCode)), , "DealTrak"
   End If
   FaxQuery = FaxItems
End Function

Function ReSendFax(FaxID As String, FaxNumber As String) As Long
   Dim Success As Double
   Dim interfax As New clsws_InterFax
   Success = interfax.wsm_ReSendFax(FaxUser, FaxPwd, FaxID, FaxNumber)
   If Success > 0 Then
      MsgBox "Fax ReSent successfully.", , "DealTrak"
   Else
      MsgBox "Fax not ReSent. Fax service error code: " & InterFaxErrorCodes(CInt(Success)), , "DealTrak"
   End If
   ReSendFax = CLng(Success)
End Function

Function InterFaxErrorCodes(ErrorCode As Integer) As String
   Select Case (ErrorCode)
   Case -112
      InterFaxErrorCodes = "No valid recipients added or missing fax number"
   Case -123
      InterFaxErrorCodes = "No valid documents attached"
   Case -150
      InterFaxErrorCodes = "Internal System Error"
   Case -1002
      InterFaxErrorCodes = "Number of types does not match number of document sizes string"
   Case -1003
      InterFaxErrorCodes = "Authentication error"
   Case -1004
      InterFaxErrorCodes = "Missing file type"
   Case -1005
      InterFaxErrorCodes = "Transaction does not exist"
   Case -1007
      InterFaxErrorCodes = "Size value is not numeric or not greater than 0"
   Case -1008
      InterFaxErrorCodes = "Total sizes does not match filesdata length"
   Case -1009
      InterFaxErrorCodes = "Image not available (may happen if the 'delete fax after completion' feature is active)"
   Case -1030
      InterFaxErrorCodes = "Invalid Verb or VerbData"
   Case -3001
      InterFaxErrorCodes = "Invalid MessageID"
   Case -3002
      InterFaxErrorCodes = "From parameter is larger than image size"
   Case -3003
      InterFaxErrorCodes = "Image doesn't exist"
   Case -3004
      InterFaxErrorCodes = "TIFF File Is Empty"
   Case -3005
      InterFaxErrorCodes = "Chunk size is smaller than 1"
   Case -3006
      InterFaxErrorCodes = "Max item is smaller than 1"
   Case -3007
      InterFaxErrorCodes = "No permission for this action (In inbound method GetList, LType is set to AccountAllMessages or AccountNewMessages, when the username is not a Primary user)"
   Case Else
      InterFaxErrorCodes = "Unknown Error"
   End Select
End Function

Function FaxStatusCodes(StatusCode As Integer) As String
   Select Case StatusCode
   Case -1
      FaxStatusCodes = "Rendering"
   Case -2
      FaxStatusCodes = "In-Queue"
   Case -3
      FaxStatusCodes = "Sending"
   Case -22
      FaxStatusCodes = "On Hold"
   Case 0
      FaxStatusCodes = "Sent"
   Case 3072
      FaxStatusCodes = "Error"
   Case 3224
      FaxStatusCodes = "No Response"
   Case 3912
      FaxStatusCodes = "No Tone"
   Case 3931
      FaxStatusCodes = "Busy"
   Case 3935
      FaxStatusCodes = "No Answer"
   Case 3936
      FaxStatusCodes = "Voice Answer"
   Case 3937
      FaxStatusCodes = "Rings Busy"
   Case 6017
      FaxStatusCodes = "Busy"
   Case 6018
      FaxStatusCodes = "No Answer"
   Case 8021
      FaxStatusCodes = "No Answer"
   Case 8025
      FaxStatusCodes = "Busy"
   Case Else
      FaxStatusCodes = "Error"
   End Select
End Function
 
Andy,
I think the problem is that Design mode is not availavle in an MDE.
Code:
If Not strLinkCriteria = "" Then
  DoCmd.OpenReport RptName, [B][COLOR="Red"]acViewDesign[/COLOR][/B]
  Reports(RptName).FilterOn = True
  Reports(RptName).Filter = strLinkCriteria
End If
 
RG - You are correct! No design changes can occur within an MDE file.
 

Users who are viewing this thread

Back
Top Bottom