N
norhaya
Hi
Please help me with my code
I am trying to email all data in my query in a formatted text from access
form.
I have searching for a while now to see any sample code to have this work,
but none seems available.
could you kindly look into this code and let me know where did I go wrong.
I really do appreciate your help very much.
norhaya
Private Sub Command645_DblClick(Cancel As Integer)
Dim dbs As Database
Dim strSQL As String, strJPL1 As String, strSubject As String, strPN As
String, strDesc As String
Dim strPartsLine As String
Dim strShipQty1 As Integer
strPN = Me.PN
strDesc = Me.DESCRIPTION
strShipQty1 = Me.SHIP_QTY1
strJPL1 = Me.JPL1
strSubject = "Testing Looping Through All records"
strPartsLine = strPartsLine & strPN & " " & strDesc & " " & strShipQty1
& vbCrLf & vbCrLf
Set dbs = CurrentDb
strSQL = "Select [2004 SHIP].* FROM [2004 ship] " & _
"WHERE ([2004 SHIP].[JPL1]) ='" & strJPL1 & "'"
strSQL = strSQL & "order by ([2004 SHIP].[JPL1]);"
Set rs = dbs.OpenRecordset(strSQL)
b = rs.RecordCount
If Not rs.EOF Then
For b = 1 To rs.RecordCount
strPartsLine = strPartsLine & rs.Fields("PN") & " " & _
rs.Fields("DESCRIPTION") & " " & rs.Fields("SHIP Qty1") & _
vbCrLf & vbCrLf
Next b
Else
MsgBox "The recordset contained no Records"
End If
Beep
DoCmd.SendObject , , acFormatTXT, varTo, varcc, varbcc, strSubject,
strPartsLine, -1
rs.Close
Set rs = Nothing
End Sub
Please help me with my code
I am trying to email all data in my query in a formatted text from access
form.
I have searching for a while now to see any sample code to have this work,
but none seems available.
could you kindly look into this code and let me know where did I go wrong.
I really do appreciate your help very much.
norhaya
Private Sub Command645_DblClick(Cancel As Integer)
Dim dbs As Database
Dim strSQL As String, strJPL1 As String, strSubject As String, strPN As
String, strDesc As String
Dim strPartsLine As String
Dim strShipQty1 As Integer
strPN = Me.PN
strDesc = Me.DESCRIPTION
strShipQty1 = Me.SHIP_QTY1
strJPL1 = Me.JPL1
strSubject = "Testing Looping Through All records"
strPartsLine = strPartsLine & strPN & " " & strDesc & " " & strShipQty1
& vbCrLf & vbCrLf
Set dbs = CurrentDb
strSQL = "Select [2004 SHIP].* FROM [2004 ship] " & _
"WHERE ([2004 SHIP].[JPL1]) ='" & strJPL1 & "'"
strSQL = strSQL & "order by ([2004 SHIP].[JPL1]);"
Set rs = dbs.OpenRecordset(strSQL)
b = rs.RecordCount
If Not rs.EOF Then
For b = 1 To rs.RecordCount
strPartsLine = strPartsLine & rs.Fields("PN") & " " & _
rs.Fields("DESCRIPTION") & " " & rs.Fields("SHIP Qty1") & _
vbCrLf & vbCrLf
Next b
Else
MsgBox "The recordset contained no Records"
End If
Beep
DoCmd.SendObject , , acFormatTXT, varTo, varcc, varbcc, strSubject,
strPartsLine, -1
rs.Close
Set rs = Nothing
End Sub