กระทู้เก่าบอร์ด อ.สุภาพ ไชยา
270 1
URL.หัวข้อ /
URL
ต้องการไม่ให้ข้อความขาดๆ เกินๆ ในการส่งอีเมลล์
ถามไว้ที่
http://www.access-programmers.co.uk/forums/showthread.php?s=&postid=113302#post113302
เขามีโค้ดข้างล่างสำหรับส่งอีเมลล์
แต่ปัญหาของเขาอยู่ที่ ถ้าบาง Text Box มันว่า จะทำให้ข้อความที่ส่งออกไปไม่สวย จะขาดๆ เกินๆ จะทำอย่างไรถ้าอันไหนว่าง ก็ให้ข้ามไป ไม่ต้องใส่
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim strTextMessage As String
strTextMessage = "The Following Instruments have now been completed for" & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & Me!txt1a & " - " & Me!txt1d & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt1b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt1c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt1f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt2b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt2c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt2f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt3b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt3c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt3f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt4b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt4c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt4f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt5b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt5c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt5f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt6b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt6c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt6f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt7b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt7c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt7f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt8b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt8c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt8f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt9b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt9c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt9f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt10b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt10c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt10f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
DoCmd.SendObject acSendNoObject, , , Me!txtemailaddressCC, Me!rds1, , "Project Code " & Me!txt1a, strTextMessage, True
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
End Sub
ผมแนะนำให้เขาใช้โค้ดต่อไปนี้ช่วย
Function fIsBlank(strField As String, I As Integer, _
Optional strString2 As String) As String
Dim strR As String
If strField <> "" Or Not IsNull(strField) Then
Select Case I
Case Is = 1
strR = "Instrument Description : -" & " " & strField & strString2
Case Is = 2
strR = "SNAP FileName : -" & " " & strField & strString2
Case Is = 3
strR = "Instrument Description : -" & " " & strField & strString2
End Select
Else
strR = ""
End If
fIsBlank = strR
End Function
โดยเปลี่ยนโค้ดของเขาดังนี้
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim strTextMessage As String
strTextMessage = "The Following Instruments have now been completed for" & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & Me!txt1a & " - " & Me!txt1d & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & fIsBlank(Me!txt1b, 1, Chr(13))
strTextMessage = strTextMessage & fIsBlank(Me!txt1b, 2, Chr(13))
strTextMessage = strTextMessage & fIsBlank(Me!txt1b, 3, Chr(13))
strTextMessage = strTextMessage & Chr(13)
.
.
.
http://www.access-programmers.co.uk/forums/showthread.php?s=&postid=113302#post113302
เขามีโค้ดข้างล่างสำหรับส่งอีเมลล์
แต่ปัญหาของเขาอยู่ที่ ถ้าบาง Text Box มันว่า จะทำให้ข้อความที่ส่งออกไปไม่สวย จะขาดๆ เกินๆ จะทำอย่างไรถ้าอันไหนว่าง ก็ให้ข้ามไป ไม่ต้องใส่
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim strTextMessage As String
strTextMessage = "The Following Instruments have now been completed for" & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & Me!txt1a & " - " & Me!txt1d & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt1b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt1c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt1f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt2b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt2c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt2f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt3b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt3c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt3f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt4b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt4c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt4f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt5b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt5c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt5f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt6b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt6c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt6f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt7b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt7c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt7f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt8b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt8c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt8f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt9b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt9c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt9f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & "Instrument Description : -" & " " & Me!txt10b & Chr(13)
strTextMessage = strTextMessage & "SNAP FileName : -" & " " & Me!txt10c & Chr(13)
strTextMessage = strTextMessage & "Number of Records : -" & " " & Me!txt10f & Chr(13)
strTextMessage = strTextMessage & Chr(13)
DoCmd.SendObject acSendNoObject, , , Me!txtemailaddressCC, Me!rds1, , "Project Code " & Me!txt1a, strTextMessage, True
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
End Sub
ผมแนะนำให้เขาใช้โค้ดต่อไปนี้ช่วย
Function fIsBlank(strField As String, I As Integer, _
Optional strString2 As String) As String
Dim strR As String
If strField <> "" Or Not IsNull(strField) Then
Select Case I
Case Is = 1
strR = "Instrument Description : -" & " " & strField & strString2
Case Is = 2
strR = "SNAP FileName : -" & " " & strField & strString2
Case Is = 3
strR = "Instrument Description : -" & " " & strField & strString2
End Select
Else
strR = ""
End If
fIsBlank = strR
End Function
โดยเปลี่ยนโค้ดของเขาดังนี้
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim strTextMessage As String
strTextMessage = "The Following Instruments have now been completed for" & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & Me!txt1a & " - " & Me!txt1d & Chr(13)
strTextMessage = strTextMessage & Chr(13)
strTextMessage = strTextMessage & fIsBlank(Me!txt1b, 1, Chr(13))
strTextMessage = strTextMessage & fIsBlank(Me!txt1b, 2, Chr(13))
strTextMessage = strTextMessage & fIsBlank(Me!txt1b, 3, Chr(13))
strTextMessage = strTextMessage & Chr(13)
.
.
.
1 Reply in this Topic. Dispaly 1 pages and you are on page number 1
1 @R06556
Time: 0.1141s