Private mstrCoLastName As String Private mstrFirstName As String Private mstrAddressLine1 As String Private mstrAddressLine2 As String Private mstrAddressLine3 As String Private mstrAddressLine4 As String Private mstrInclusive As String Private mstrInvoiceNumber As String Private mstrSaleDate As String Private mstrCustomersNumber As String Private mstrShipVia As String Private mstrDeliveryStatus As String Private mstrDescription As String Private mlngAccountNumber As Long Private mdblExTaxAmount As Double Private mdblIncTaxAmount As Double Private mstrJob As String Private mstrComment As String Private mstrMemo As String Private mstrSalespersonLastName As String Private mstrSalespersonFirstName As String Private mstrShippingDate As String Private mstrReferralSource As String Private mstrTaxCode As String Private mdblNonGSTLCTAmount As Double Private mdblGSTAmount As Double Private mdblLCTAmount As Double Private mdblFreightExTaxAmount As Double Private mdblFreightIncTaxAmount As Double Private mstrFreightTaxCode As String Private mdblFreightNonGSTLCTAmount As Double Private mdblFreightLCTAmount As Double Private mdblFreightGSTAmount As Double Private mstrSaleStatus As String Private mstrCurrencyCode As String Private mdblExchangeRate As Double Private mintPaymentIsDue As Integer Private mintDiscountDays As Integer Private mintBalanceDueDays As Integer Private mdblPercentDiscount As Double Private mdblPercentMonthlyCharge As Double Private mdblAmountPaid As Double Private mstrPaymentMethod As String Private mstrPaymentNotes As String Private mstrNameOnCard As String Private mstrCardNumber As String Private mstrExpiryDate As String Private mstrAuthorisationCode As String Private mstrDrawerBSB As String Private mlngDrawerAccountNumber As Long Private mstrDrawerAccountName As String Private mstrDrawerChequeNumber As String Private mstrCategory As String Private mstrCardID As String Private mstrRecordID As String Private cn As ADODB.Connection Private mstrSQLDest As String Private mstrSQLArgs As String Private Const CLASS_NAME = "clsMYOBServiceSale" Public Sub CreateServiceSale() Dim cmd As ADODB.Command Dim strSQL As String 'On Error GoTo Proc_Err If cn Is Nothing Then If MYOBConnection Is Nothing Then Set MYOBConnection = New clsMYOBConnection End If If MYOBConnection.cn Is Nothing Then Set cn = MYOBConnection.CreateConnection Else Set cn = MYOBConnection.cn End If End If Set cmd = New ADODB.Command strSQL = "INSERT INTO Import_Service_Sales " DetermineDestinationFields ValidateRequiredFields If mstrSQLDest <> "" And mstrSQLArgs <> "" Then cn.BeginTrans strSQL = strSQL & "(" & mstrSQLDest & ") VALUES (" & mstrSQLArgs & ")" With cmd Set .ActiveConnection = cn .CommandText = strSQL .CommandType = adCmdText .Execute , , adExecuteNoRecords '.CommandText = "END TRANSACTION" '.Execute , , adExecuteNoRecords End With cn.CommitTrans End If Proc_Exit: On Error Resume Next Set cmd.ActiveConnection = Nothing Set cmd = Nothing End Sub Public Function FindSale(Optional strInvoiceNumber As String, _ Optional strJobNumber As String) As Variant Dim rs As ADODB.Recordset Dim strSQL As String Dim strSQL1 As String Dim strSQL2 As String On Error GoTo Proc_Err If cn Is Nothing Then If MYOBConnection Is Nothing Then Set MYOBConnection = New clsMYOBConnection End If If MYOBConnection.cn Is Nothing Then Set cn = MYOBConnection.CreateConnection Else Set cn = MYOBConnection.cn End If End If Set rs = New ADODB.Recordset strSQL = "SELECT MYOB.Sales.SaleID, " & _ "MYOB.SaleLines.SaleLineID, " & _ "MYOB.Sales.InvoiceNumber, " & _ "MYOB.Jobs.JobNumber " & _ "FROM MYOB.Jobs INNER JOIN " & _ "(MYOB.Sales INNER JOIN " & _ "MYOB.SaleLines ON MYOB.Sales.SaleID = MYOB.SaleLines.SaleID) " & _ "ON MYOB.Jobs.JobID = MYOB.SaleLines.JobID " strSQL1 = IIf(strInvoiceNumber = "", "", "MYOB.Sales.InvoiceNumber = '" & strInvoiceNumber & "'") strSQL2 = IIf(strJobNumber = "", "", "MYOB.Jobs.JobNumber = '" & strJobNumber & "'") If strInvoiceNumber <> "" And strJobNumber <> "" Then strSQL2 = " AND " & strSQL2 End If rs.Open strSQL & strSQL1 & strSQL2, cn, adOpenStatic, adLockReadOnly If Not (rs.BOF And rs.EOF) Then FindSale = rs!SaleID Else FindSale = Null End If Proc_Exit: On Error Resume Next rs.Close Set rs = Nothing Exit Function Proc_Err: DoCmd.Beep FindSale = Null Resume Proc_Exit Resume End Function Public Property Let CoLastName(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 50 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrCoLastName = strNewValue End Property Public Property Get CoLastName() As String CoLastName = mstrCoLastName End Property Public Property Let FirstName(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 20 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrFirstName = strNewValue End Property Public Property Get FirstName() As String FirstName = mstrFirstName End Property Public Property Let AddressLine1(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 255 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrAddressLine1 = strNewValue End Property Public Property Get AddressLine1() As String AddressLine1 = mstrAddressLine1 End Property Public Property Let AddressLine2(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 253 - Len(mstrAddressLine1) Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrAddressLine2 = strNewValue End Property Public Property Get AddressLine2() As String AddressLine2 = mstrAddressLine2 End Property Public Property Let AddressLine3(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 251 - (Len(mstrAddressLine1) + Len(mstrAddressLine2)) Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrAddressLine3 = strNewValue End Property Public Property Get AddressLine3() As String AddressLine3 = mstrAddressLine3 End Property Public Property Let AddressLine4(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 249 - (Len(mstrAddressLine1) + Len(mstrAddressLine2) + Len(mstrAddressLine3)) Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrAddressLine4 = strNewValue End Property Public Property Get AddressLine4() As String AddressLine4 = mstrAddressLine4 End Property Public Property Let Inclusive(strNewValue As String) If Len(strNewValue) > 1 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrInclusive = strNewValue End Property Public Property Get Inclusive() As String Inclusive = mstrInclusive End Property Public Property Let InvoiceNumber(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 8 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrInvoiceNumber = strNewValue End Property Public Property Get InvoiceNumber() As String InvoiceNumber = mstrInvoiceNumber End Property Public Property Let SaleDate(dteNewValue As Date) mstrSaleDate = CStr(dteNewValue) End Property Public Property Get SaleDate() As Date SaleDate = CDate(mstrSaleDate) End Property Public Property Let CustomersNumber(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 20 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrCustomersNumber = strNewValue End Property Public Property Get CustomersNumber() As String CustomersNumber = mstrCustomersNumber End Property Public Property Let ShipVia(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 20 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrShipVia = strNewValue End Property Public Property Get ShipVia() As String ShipVia = mstrShipVia End Property Public Property Let DeliveryStatus(strNewValue As String) If Len(strNewValue) > 1 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property Else Select Case strNewValue Case "P" 'to be printed Case "E" 'to be emailed Case "B" 'to be printed and emailed Case "A" 'already printed or sent Case Else Err.Raise vbObjectError + 5, CLASS_NAME, GetErrorMessage(5) Exit Property End Select End If mstrDeliveryStatus = strNewValue End Property Public Property Get DeliveryStatus() As String DeliveryStatus = mstrDeliveryStatus End Property Public Property Let Description(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 255 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrDescription = strNewValue End Property Public Property Get Description() As String Description = mstrDescription End Property Public Property Let AccountNumber(lngNewValue As Long) If lngNewValue < 0 Or lngNewValue > 99999 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mlngAccountNumber = lngNewValue End Property Public Property Get AccountNumber() As Long AccountNumber = mlngAccountNumber End Property Public Property Let ExTaxAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblExTaxAmount = dblNewValue End Property Public Property Get ExTaxAmount() As Double ExTaxAmount = mdblExTaxAmount End Property Public Property Let IncTaxAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblIncTaxAmount = dblNewValue End Property Public Property Get IncTaxAmount() As Double IncTaxAmount = mdblIncTaxAmount End Property Public Property Let Job(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 15 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrJob = strNewValue End Property Public Property Get Job() As String Job = mstrJob End Property Public Property Let Comment(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 255 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrComment = strNewValue End Property Public Property Get Comment() As String Comment = mstrComment End Property Public Property Let Memo(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 255 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrMemo = strNewValue End Property Public Property Get Memo() As String Memo = mstrMemo End Property Public Property Let SalespersonLastName(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 50 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrSalespersonLastName = strNewValue End Property Public Property Get SalespersonLastName() As String SalespersonLastName = mstrSalespersonLastName End Property Public Property Let SalespersonFirstName(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 20 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrSalespersonFirstName = strNewValue End Property Public Property Get SalespersonFirstName() As String SalespersonFirstName = mstrSalespersonFirstName End Property Public Property Let ShippingDate(dteNewValue As Date) mstrShippingDate = CStr(dteNewValue) End Property Public Property Get ShippingDate() As Date ShippingDate = CDate(mstrShippingDate) End Property Public Property Let ReferralSource(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 20 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrReferralSource = strNewValue End Property Public Property Get ReferralSource() As String ReferralSource = mstrReferralSource End Property Public Property Let TaxCode(strNewValue As String) If Len(strNewValue) > 3 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrTaxCode = strNewValue End Property Public Property Get TaxCode() As String TaxCode = mstrTaxCode End Property Public Property Let NonGSTLCTAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblNonGSTLCTAmount = dblNewValue End Property Public Property Get NonGSTLCTAmount() As Double NonGSTLCTAmount = mdblNonGSTLCTAmount End Property Public Property Let GSTAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblGSTAmount = dblNewValue End Property Public Property Get GSTAmount() As Double GSTAmount = mdblGSTAmount End Property Public Property Let LCTAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblLCTAmount = dblNewValue End Property Public Property Get LCTAmount() As Double LCTAmount = mdblLCTAmount End Property Public Property Let FreightExTaxAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblFreightExTaxAmount = dblNewValue End Property Public Property Get FreightExTaxAmount() As Double FreightExTaxAmount = mdblFreightExTaxAmount End Property Public Property Let FreightIncTaxAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblFreightIncTaxAmount = dblNewValue End Property Public Property Get FreightIncTaxAmount() As Double FreightIncTaxAmount = mdblFreightIncTaxAmount End Property Public Property Let FreightTaxCode(strNewValue As String) If Len(strNewValue) > 3 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrFreightTaxCode = strNewValue End Property Public Property Get FreightTaxCode() As String FreightTaxCode = mstrFreightTaxCode End Property Public Property Let FreightNonGSTLCTAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblFreightNonGSTLCTAmount = dblNewValue End Property Public Property Get FreightNonGSTLCTAmount() As Double FreightNonGSTLCTAmount = mdblFreightNonGSTLCTAmount End Property Public Property Let FreightLCTAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblFreightLCTAmount = dblNewValue End Property Public Property Get FreightLCTAmount() As Double FreightLCTAmount = mdblFreightLCTAmount End Property Public Property Let FreightGSTAmount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblFreightGSTAmount = dblNewValue End Property Public Property Get FreightGSTAmount() As Double FreightGSTAmount = mdblFreightGSTAmount End Property Public Property Let SaleStatus(strNewValue As String) If Len(strNewValue) > 1 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property Else Select Case strNewValue Case "Q" 'Quote Case "O" 'Order Case "I" 'Invoice Case Else Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End Select End If mstrSaleStatus = strNewValue End Property Public Property Get SaleStatus() As String SaleStatus = mstrSaleStatus End Property Public Property Let CurrencyCode(strNewValue As String) If Len(strNewValue) > 3 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrCurrencyCode = strNewValue End Property Public Property Get CurrencyCode() As String CurrencyCode = mstrCurrencyCode End Property Public Property Let ExchangeRate(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 999999.999999 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblExchangeRate = dblNewValue End Property Public Property Get ExchangeRate() As Double ExchangeRate = mdblExchangeRate End Property Public Property Let PaymentIsDue(intNewValue As Integer) Select Case intNewValue Case 0 'COD Case 1 'Prepaid Case 2 'In a given number of days Case 3 'On a day of the month Case 4 'Number of days after end-of-month Case 5 'Day of the month after end-of-month Case Else Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End Select mintPaymentIsDue = intNewValue End Property Public Property Get PaymentIsDue() As Integer PaymentIsDue = mintPaymentIsDue End Property Public Property Let DiscountDays(intNewValue As Integer) If intNewValue < 0 Or intNewValue > 999 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mintDiscountDays = intNewValue End Property Public Property Get DiscountDays() As Integer DiscountDays = mintDiscountDays End Property Public Property Let BalanceDueDays(intNewValue As Integer) If intNewValue < 0 Or intNewValue > 999 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mintBalanceDueDays = intNewValue End Property Public Property Get BalanceDueDays() As Integer BalanceDueDays = mintBalanceDueDays End Property Public Property Let PercentDiscount(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 1 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblPercentDiscount = dblNewValue End Property Public Property Get PercentDiscount() As Double PercentDiscount = mdblPercentDiscount End Property Public Property Let PercentMonthlyCharge(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 1 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblPercentMonthlyCharge = dblNewValue End Property Public Property Get PercentMonthlyCharge() As Double PercentMonthlyCharge = mdblPercentMonthlyCharge End Property Public Property Let AmountPaid(dblNewValue As Double) If dblNewValue < 0 Or dblNewValue > 9999999999999.99 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mdblAmountPaid = dblNewValue End Property Public Property Get AmountPaid() As Double AmountPaid = mdblAmountPaid End Property Public Property Let PaymentMethod(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 20 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrPaymentMethod = strNewValue End Property Public Property Get PaymentMethod() As String PaymentMethod = mstrPaymentMethod End Property Public Property Let PaymentNotes(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 255 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrPaymentNotes = strNewValue End Property Public Property Get PaymentNotes() As String PaymentNotes = mstrPaymentNotes End Property Public Property Let NameOnCard(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 50 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrNameOnCard = strNewValue End Property Public Property Get NameOnCard() As String NameOnCard = mstrNameOnCard End Property Public Property Let CardNumber(strNewValue As String) If Len(strNewValue) > 25 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrCardNumber = strNewValue End Property Public Property Get CardNumber() As String CardNumber = mstrCardNumber End Property Public Property Let ExpiryDate(strNewValue As String) Dim intPos As Integer Dim intMonth As Integer If Len(strNewValue) > 5 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property ElseIf Not (strNewValue Like "#/##") Then Err.Raise vbObjectError + 6, CLASS_NAME, GetErrorMessage(6) Exit Property Else intPos = InStr(1, strNewValue, "/") If intPos = 0 Then Err.Raise vbObjectError + 6, CLASS_NAME, GetErrorMessage(6) Exit Property Else intMonth = Val(Left(strNewValue, intPos - 1)) If intMonth < 1 Or intMonth > 12 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If End If End If mstrExpiryDate = strNewValue End Property Public Property Get ExpiryDate() As String ExpiryDate = mstrExpiryDate End Property Public Property Let AuthorisationCode(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 255 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrAuthorisationCode = strNewValue End Property Public Property Get AuthorisationCode() As String AuthorisationCode = mstrAuthorisationCode End Property Public Property Let DrawerBSB(strNewValue As String) Dim intPos As Integer Dim intLeftNum As Integer Dim intRightNum As Integer If Len(strNewValue) > 7 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property ElseIf Not (strNewValue Like "###-###") Then Err.Raise vbObjectError + 6, CLASS_NAME, GetErrorMessage(6) Exit Property Else intPos = InStr(1, strNewValue, "-") If intPos = 0 Then Err.Raise vbObjectError + 7, CLASS_NAME, GetErrorMessage(7) Exit Property Else intLeftNum = Left(strNewValue, intPos - 1) intRightNum = Mid(strNewValue, intPos + 1) If (intLeftNum < 0 Or intLeftNum > 999) Or (intRightNum < 0 Or intRightNum > 999) Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If End If End If mstrDrawerBSB = strNewValue End Property Public Property Get DrawerBSB() As String DrawerBSB = mstrDrawerBSB End Property Public Property Let DrawerAccountNumber(lngNewValue As Long) If lngNewValue < 0 Or lngNewValue > 999999999 Then Err.Raise vbObjectError + 2, CLASS_NAME, GetErrorMessage(2) Exit Property End If mlngDrawerAccountNumber = lngNewValue End Property Public Property Get DrawerAccountNumber() As Long DrawerAccountNumber = mlngDrawerAccountNumber End Property Public Property Let DrawerAccountName(strNewValue As String) Dim intChar As Integer strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 32 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property Else For intChar = 1 To Len(strNewValue) Select Case Asc(Mid(strNewValue, intChar, 1)) Case 38, 45, 46, 47, 65 To 90, 97 To 122 Case Else Err.Raise vbObjectError + 5, CLASS_NAME, GetErrorMessage(5) Exit Property End Select Next intChar End If mstrDrawerAccountName = strNewValue End Property Public Property Get DrawerAccountName() As String DrawerAccountName = mstrDrawerAccountName End Property Public Property Let DrawerChequeNumber(strNewValue As String) If Len(strNewValue) > 25 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrDrawerChequeNumber = strNewValue End Property Public Property Get DrawerChequeNumber() As String DrawerChequeNumber = mstrDrawerChequeNumber End Property Public Property Let Category(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 15 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrCategory = strNewValue End Property Public Property Get Category() As String Category = mstrCategory End Property Public Property Let CardID(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 15 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrCardID = strNewValue End Property Public Property Get CardID() As String CardID = mstrCardID End Property Public Property Let RecordID(strNewValue As String) strNewValue = Replace(Replace(Trim(strNewValue), """", "''"), "'", "''") If Len(strNewValue) > 10 Then Err.Raise vbObjectError + 1, CLASS_NAME, GetErrorMessage(1) Exit Property End If mstrRecordID = strNewValue End Property Public Property Get RecordID() As String RecordID = mstrRecordID End Property Private Sub DetermineDestinationFields() If mstrCoLastName <> "" Then mstrSQLDest = "CoLastName," mstrSQLArgs = "'" & mstrCoLastName & "'," End If If mstrFirstName <> "" Then mstrSQLDest = mstrSQLDest & "FirstName," mstrSQLArgs = mstrSQLArgs & "'" & mstrCoLastName & "'," End If If mstrAddressLine1 <> "" Then mstrSQLDest = mstrSQLDest & "AddressLine1," mstrSQLArgs = mstrSQLArgs & "'" & mstrAddressLine1 & "'," End If If mstrAddressLine2 <> "" Then mstrSQLDest = mstrSQLDest & "AddressLine2," mstrSQLArgs = mstrSQLArgs & "'" & mstrAddressLine2 & "'," End If If mstrAddressLine3 <> "" Then mstrSQLDest = mstrSQLDest & "AddressLine3," mstrSQLArgs = mstrSQLArgs & "'" & mstrAddressLine3 & "'," End If If mstrAddressLine4 <> "" Then mstrSQLDest = mstrSQLDest & "AddressLine4," mstrSQLArgs = mstrSQLArgs & "'" & mstrAddressLine4 & "'," End If If mstrInclusive <> "" Then mstrSQLDest = mstrSQLDest & "Inclusive," mstrSQLArgs = mstrSQLArgs & "'" & mstrInclusive & "'," End If If mstrInvoiceNumber <> "" Then mstrSQLDest = mstrSQLDest & "InvoiceNumber," mstrSQLArgs = mstrSQLArgs & "'" & mstrInvoiceNumber & "'," End If If mstrSaleDate <> "" Then mstrSQLDest = mstrSQLDest & "SalesDate," mstrSQLArgs = mstrSQLArgs & "'" & mstrSaleDate & "'," End If If mstrCustomersNumber <> "" Then mstrSQLDest = mstrSQLDest & "CustomersNumber," mstrSQLArgs = mstrSQLArgs & "'" & mstrCustomersNumber & "'," End If If mstrShipVia <> "" Then mstrSQLDest = mstrSQLDest & "ShipVia," mstrSQLArgs = mstrSQLArgs & "'" & mstrShipVia & "'," End If If mstrDeliveryStatus <> "" Then mstrSQLDest = mstrSQLDest & "DeliveryStatus," mstrSQLArgs = mstrSQLArgs & "'" & mstrDeliveryStatus & "'," End If If mstrDescription <> "" Then mstrSQLDest = mstrSQLDest & "Description," mstrSQLArgs = mstrSQLArgs & "'" & mstrDescription & "'," End If mstrSQLDest = mstrSQLDest & "AccountNumber," mstrSQLArgs = mstrSQLArgs & mlngAccountNumber & "," mstrSQLDest = mstrSQLDest & "ExTaxAmount," mstrSQLArgs = mstrSQLArgs & mdblExTaxAmount & "," mstrSQLDest = mstrSQLDest & "IncTaxAmount," mstrSQLArgs = mstrSQLArgs & mdblIncTaxAmount & "," If mstrJob <> "" Then mstrSQLDest = mstrSQLDest & "Job," mstrSQLArgs = mstrSQLArgs & "'" & mstrJob & "'," End If If mstrComment <> "" Then mstrSQLDest = mstrSQLDest & "Comment," mstrSQLArgs = mstrSQLArgs & "'" & mstrComment & "'," End If If mstrMemo <> "" Then mstrSQLDest = mstrSQLDest & "Memo," mstrSQLArgs = mstrSQLArgs & "'" & mstrMemo & "'," End If If mstrSalespersonLastName <> "" Then mstrSQLDest = mstrSQLDest & "SalespersonLastName," mstrSQLArgs = mstrSQLArgs & "'" & mstrSalespersonLastName & "'," End If If mstrSalespersonFirstName <> "" Then mstrSQLDest = mstrSQLDest & "SalespersonFirstName," mstrSQLArgs = mstrSQLArgs & "'" & mstrSalespersonFirstName & "'," End If If mstrShippingDate <> "" Then mstrSQLDest = mstrSQLDest & "ShippingDate," mstrSQLArgs = mstrSQLArgs & "'" & mstrShippingDate & "'," End If If mstrReferralSource <> "" Then mstrSQLDest = mstrSQLDest & "ReferralSource," mstrSQLArgs = mstrSQLArgs & "'" & mstrReferralSource & "'," End If If mstrTaxCode <> "" Then mstrSQLDest = mstrSQLDest & "TaxCode," mstrSQLArgs = mstrSQLArgs & "'" & mstrTaxCode & "'," End If mstrSQLDest = mstrSQLDest & "NonGSTLCTAmount," mstrSQLArgs = mstrSQLArgs & mdblNonGSTLCTAmount & "," mstrSQLDest = mstrSQLDest & "GSTAmount," mstrSQLArgs = mstrSQLArgs & mdblGSTAmount & "," mstrSQLDest = mstrSQLDest & "LCTAmount," mstrSQLArgs = mstrSQLArgs & mdblLCTAmount & "," mstrSQLDest = mstrSQLDest & "FreightExTaxAmount," mstrSQLArgs = mstrSQLArgs & mdblFreightExTaxAmount & "," mstrSQLDest = mstrSQLDest & "FreightIncTaxAmount," mstrSQLArgs = mstrSQLArgs & mdblFreightIncTaxAmount & "," If mstrFreightTaxCode <> "" Then mstrSQLDest = mstrSQLDest & "FreightTaxCode," mstrSQLArgs = mstrSQLArgs & "'" & mstrFreightTaxCode & "'," End If mstrSQLDest = mstrSQLDest & "FreightNonGSTLCTAmount," mstrSQLArgs = mstrSQLArgs & mdblFreightNonGSTLCTAmount & "," mstrSQLDest = mstrSQLDest & "FreightLCTAmount," mstrSQLArgs = mstrSQLArgs & mdblFreightLCTAmount & "," mstrSQLDest = mstrSQLDest & "FreightGSTAmount," mstrSQLArgs = mstrSQLArgs & mdblFreightGSTAmount & "," If mstrSaleStatus <> "" Then mstrSQLDest = mstrSQLDest & "SaleStatus," mstrSQLArgs = mstrSQLArgs & "'" & mstrSaleStatus & "'," End If If mstrCurrencyCode <> "" Then mstrSQLDest = mstrSQLDest & "CurrencyCode," mstrSQLArgs = mstrSQLArgs & "'" & mstrCurrencyCode & "'," End If mstrSQLDest = mstrSQLDest & "ExchangeRate," mstrSQLArgs = mstrSQLArgs & mdblExchangeRate & "," mstrSQLDest = mstrSQLDest & "PaymentIsDue," mstrSQLArgs = mstrSQLArgs & mintPaymentIsDue & "," mstrSQLDest = mstrSQLDest & "DiscountDays," mstrSQLArgs = mstrSQLArgs & mintDiscountDays & "," mstrSQLDest = mstrSQLDest & "BalanceDueDays," mstrSQLArgs = mstrSQLArgs & mintBalanceDueDays & "," mstrSQLDest = mstrSQLDest & "PercentDiscount," mstrSQLArgs = mstrSQLArgs & mdblPercentDiscount & "," mstrSQLDest = mstrSQLDest & "PercentMonthlyCharge," mstrSQLArgs = mstrSQLArgs & mdblPercentMonthlyCharge & "," mstrSQLDest = mstrSQLDest & "AmountPaid," mstrSQLArgs = mstrSQLArgs & mdblAmountPaid & "," If mstrPaymentMethod <> "" Then mstrSQLDest = mstrSQLDest & "PaymentMethod," mstrSQLArgs = mstrSQLArgs & "'" & mstrPaymentMethod & "'," End If If mstrPaymentNotes <> "" Then mstrSQLDest = mstrSQLDest & "PaymentNotes," mstrSQLArgs = mstrSQLArgs & "'" & mstrPaymentNotes & "'," End If If mstrNameOnCard <> "" Then mstrSQLDest = mstrSQLDest & "NameOnCard," mstrSQLArgs = mstrSQLArgs & "'" & mstrNameOnCard & "'," End If If mstrCardNumber <> "" Then mstrSQLDest = mstrSQLDest & "CardNumber," mstrSQLArgs = mstrSQLArgs & "'" & mstrCardNumber & "'," End If If mstrExpiryDate <> "" Then mstrSQLDest = mstrSQLDest & "ExpiryDate," mstrSQLArgs = mstrSQLArgs & "'" & mstrExpiryDate & "'," End If If mstrAuthorisationCode <> "" Then mstrSQLDest = mstrSQLDest & "AuthorisationCode," mstrSQLArgs = mstrSQLArgs & "'" & mstrAuthorisationCode & "'," End If If mstrDrawerBSB <> "" Then mstrSQLDest = mstrSQLDest & "DrawerBSB," mstrSQLArgs = mstrSQLArgs & "'" & mstrDrawerBSB & "'," End If mstrSQLDest = mstrSQLDest & "DrawerAccountNumber," mstrSQLArgs = mstrSQLArgs & mlngDrawerAccountNumber & "," If mstrDrawerAccountName <> "" Then mstrSQLDest = mstrSQLDest & "DrawerAccountName," mstrSQLArgs = mstrSQLArgs & "'" & mstrDrawerAccountName & "'," End If If mstrDrawerChequeNumber <> "" Then mstrSQLDest = mstrSQLDest & "DrawerChequeNumber," mstrSQLArgs = mstrSQLArgs & "'" & mstrDrawerChequeNumber & "'," End If If mstrCategory <> "" Then mstrSQLDest = mstrSQLDest & "Category," mstrSQLArgs = mstrSQLArgs & "'" & mstrCategory & "'," End If 'If mstrCardID <> "" Then ' mstrSQLDest = mstrSQLDest & "CardID," ' mstrSQLArgs = mstrSQLArgs & "'" & mstrCardID & "'," 'End If 'If mstrRecordID <> "" Then ' mstrSQLDest = mstrSQLDest & "RecordID," ' mstrSQLArgs = mstrSQLArgs & "'" & mstrRecordID & "'," 'End If 'Remove the trailing comma if it exists If mstrSQLDest <> "" Then mstrSQLDest = Left(mstrSQLDest, Len(mstrSQLDest) - 1) If mstrSQLArgs <> "" Then mstrSQLArgs = Left(mstrSQLArgs, Len(mstrSQLArgs) - 1) End Sub Private Sub ValidateRequiredFields() Dim strMessage As String Dim intError As Integer intError = 1 If Len(mstrFirstName) > 0 And Len(mstrCoLastName) > 30 Then strMessage = "CoLastName is to large." GoTo Proc_Err End If If mstrCardID = "" And mstrCoLastName = "" And mstrRecordID = "" Then intError = 2 strMessage = "CardID or RecordID is missing." GoTo Proc_Err End If If Len(mstrAddressLine2) > 253 - Len(mstrAddressLine1) Then strMessage = "AddressLine2 is to large." GoTo Proc_Err ElseIf Len(mstrAddressLine3) > 251 - (Len(mstrAddressLine2) + Len(mstrAddressLine1)) Then strMessage = "AddressLine3 is to large." GoTo Proc_Err ElseIf Len(mstrAddressLine4) > 249 - (Len(mstrAddressLine3) + Len(mstrAddressLine2) + Len(mstrAddressLine1)) Then strMessage = "AddressLine4 is to large." GoTo Proc_Err End If If mlngAccountNumber = 0 Then intError = 8 strMessage = "AccountNumber is missing." GoTo Proc_Err End If If mdblExTaxAmount = 0 Then intError = 8 strMessage = "ExTaxAmount is missing." GoTo Proc_Err End If If mdblIncTaxAmount = 0 Then intError = 8 strMessage = "IncTaxAmount is missing." GoTo Proc_Err End If If Len(mstrSalespersonFirstName) > 0 And Len(mstrSalespersonLastName) > 30 Then strMessage = "SalespersonLastName is to large." GoTo Proc_Err End If Proc_Exit: Exit Sub Proc_Err: Err.Raise vbObjectError + intError, "ValidateRequiredFields", strMessage End Sub Sub InitializeVariables() 'This procedure exists only if needed in the future Exit Sub mstrCoLastName = "" mstrFirstName = "" mstrAddressLine1 = "" mstrAddressLine2 = "" mstrAddressLine3 = "" mstrAddressLine4 = "" mstrInclusive = "" mstrInvoiceNumber = "" mstrSaleDate = "" mstrCustomersNumber = "" mstrShipVia = "" mstrDeliveryStatus = "" mstrDescription = "" 'mlngAccountNumber As Integer 'mdblExTaxAmount As Double 'mdblIncTaxAmount As Double mstrJob = "" mstrComment = "" mstrMemo = "" mstrSalespersonLastName = "" mstrSalespersonFirstName = "" mstrShippingDate = "" mstrReferralSource = "" mstrTaxCode = "" 'mdblNonGSTLCTAmount As Double 'mdblGSTAmount As Double 'mdblLCTAmount As Double 'mdblFreightExTaxAmount As Double 'mdblFreightIncTaxAmount As Double mstrFreightTaxCode = "" 'mdblFreightNonGSTLCTAmount As Double 'mdblFreightLCTAmount As Double 'mdblFreightGSTAmount As Double mstrSaleStatus = "" mstrCurrencyCode = "" 'mdblExchangeRate As Double 'mintPaymentIsDue As Integer 'mintDiscountDays As Integer 'mintBalanceDueDays As Integer 'mdblPercentDiscount As Double 'mdblPercentMonthlyCharge As Double 'mdblAmountPaid As Double mstrPaymentMethod = "" mstrPaymentNotes = "" mstrNameOnCard = "" mstrCardNumber = "" mstrExpiryDate = "" mstrAuthorisationCode = "" mstrDrawerBSB = "" 'mlngDrawerAccountNumber As Long mstrDrawerAccountName = "" mstrDrawerChequeNumber = "" mstrCategory = "" mstrCardID = "" mstrRecordID = "" End Sub Private Sub Class_Initialize() InitializeVariables 'Set MYOBConnection = New clsMYOBConnection End Sub Private Sub Class_Terminate() On Error Resume Next cn.Close Set cn = Nothing End Sub