All of this code works just fine during debugging and will work just fine with a full compile as well. It is only the executable that fails.
I do have a couple of arrays in the class module.
Code:
Private Function ParseCLA()
Dim tArray() As String ' Temporary String array to hold all parsed arguments
' Use the split function to parse out all arguments into an array
tArray() = Split(Command, ";")
' Takes the first 3 arguments and assigns them to the global variables
gSpinLoc = tArray(0)
gCurrentUser = tArray(1)
gCurrentBrokerID = tArray(2)
End Function
I have a private type for the module as well that is used in an array:
Code:
Private Type AccountSettings
sHostName As String ' Holds the full hostname URL
sEADD As String ' Email address of the account
sRPort As Integer ' Port to retrieve email on. Standard is 143
sUseSSL As Boolean ' SSL is required or not
sUName As String ' Username for the account
sPass As String ' Password for the account
sAccountName As String ' Friendly name of the account
sFullName As String ' Full Name of the user
sPlainTextPass As Boolean ' If a plain text password should be used
End Type
This is the code that uses the type in an array:
Code:
Private Function GetPrimaryEmailSettings()
Dim tRST As ADODB.Recordset ' Temporary recordset to obtain email settings
Dim tErr As Integer ' Holds custom error code
Dim tNum As Integer ' Temporary variable to move through the recordset
' Set the error code to 0
tErr = 0
' Open the connection to SArtData.mdb
DCON.SARTDATA.Open
' Determine how many email accounts exist
Set tRST = DCON.SARTDATA.Execute("SELECT Count(*) As Amount FROM [EMAIL-ACCOUNTS]")
' If no email accounts exist then trigger an error and terminate the program,
' otherwise initiate the gESA() array to contain the number of accounts found
If tRST!Amount <= 0 Then
tErr = 1
GoTo PrimaryAccountError
Else
ReDim gESA(1 To tRST!Amount) As AccountSettings
End If
' Grab just the Primary Account
Set tRST = DCON.SARTDATA.Execute("SELECT * FROM [EMAIL-ACCOUNTS] WHERE PRIMARYACCOUNT = -1")
' If no Primary Account exists then trigger an error and terminate the program
If tRST.EOF = True Then
tErr = 2
GoTo PrimaryAccountError
End If
' Set the first element in gESA() to the primary account settings
gESA(1).sEADD = tRST!Email_Address
gESA(1).sHostName = tRST!Host_Incoming
gESA(1).sPass = tRST!Email_Password
gESA(1).sRPort = tRST!Port_Incoming
gESA(1).sUName = tRST!User_Name
gESA(1).sUseSSL = tRST!SSL_IN
gESA(1).sAccountName = tRST!Account_Name
gESA(1).sPlainTextPass = tRST!PlainTextPass
gESA(1).sFullName = tRST!Full_Name
' Grab all the secondary accounts
Set tRST = DCON.SARTDATA.Execute("SELECT * FROM [EMAIL-ACCOUNTS] WHERE PRIMARYACCOUNT = 0")
' Loop through the accounts and set the gESA()
If tRST.EOF = False Then tRST.MoveFirst
tNum = 2 ' This is set to 2 since it is the beginning of the secondary accounts in gESA()
Do While Not tRST.EOF
gESA(tNum).sEADD = tRST!Email_Address
gESA(tNum).sHostName = tRST!Host_Incoming
gESA(tNum).sPass = tRST!Email_Password
gESA(tNum).sRPort = tRST!Port_Incoming
gESA(tNum).sUName = tRST!User_Name
gESA(tNum).sUseSSL = tRST!SSL_IN
gESA(tNum).sAccountName = tRST!Account_Name
gESA(tNum).sPlainTextPass = tRST!PlainTextPass
gESA(tNum).sFullName = tRST!Full_Name
tNum = tNum + 1
tRST.MoveNext
Loop
' Close the data connection and set the recordset object to nothing
DCON.SARTDATA.Close
Set tRST = Nothing
Exit Function
' Custom error. Will inform the user if no accounts exist or if a primary account does not exist.
PrimaryAccountError:
If tErr = 1 Then
RaiseEvent AccountError(1)
End If
If tErr = 2 Then
RaiseEvent AccountError(2)
End If
End Function