Code Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon

    Code Problem

    Can any one see a problem with this code ( it does not work

    Private Sub cmdEmailOrderPl aced_Click()
    'On Error GoTo Error_Handler
    Dim strTo As String
    Dim strBody As String
    Dim strSubject As String
    Dim strItemsOrdered As String
    Dim CRS1 As ADODB.Recordset
    Dim strSql As String
    Set CRS1 = New ADODB.Recordset

    sstrSql = "SELECT * FROM tblOrderProduct WHERE OrderNumber =" &
    Me.OrderNumber


    CRS1.Open strSql, CurrentProject. Connection, adOpenKeyset,
    adLockReadOnly
    While Not CRS1.EOF

    strItemsOrdered = strItemsOrdered & "Item : " &
    DLookup("[ProductName]", "tblProduct ", "[ProductCode] =" &
    CRS1.Fields("Pr oductCode"))

    strItemsOrdered = strItemsOrdered & "Unit Price : " & Chr(163) &
    DLookup("[PriceIncVAT ]", "tblProduct ", "[ProductID] =" &
    CRS1.Fields("Pr oductID")) & vbCrLf





    '& vbCrLf & "Total Excl VAT: " & Chr(163) &
    Format(CRS1.Fie lds("TotalExVAT "), "##0.00")

    If IsNull(CRS1.Fie lds("Discount") ) Or CRS1.Fields("Di scount") = 0
    Then
    'Don't put discount in there if there isn't one
    Else
    strItemsOrdered = strItemsOrdered & "Discount : " &
    CRS1.Fields("Di scount") & "%" & vbCrLf
    End If
    strItemsOrdered = strItemsOrdered & "Total (Inc VAT): " & Chr(163)
    & Format(CRS1.Fie lds("TotalIncVA T"), "##0.00") & vbCrLf & vbCrLf
    CRS1.MoveNext
    Wend
    CRS1.Close
    Set CRS1 = Nothing

Working...