提前感谢:),我试图在邮件正文中附加子表单的数据。
Thanks in advance :), I am trying to attach the data of subform also in mail body.
当前状态:我可以附加主表格数据和生成邮件但无法附加子表单的数据,因为它只包含第一行,Tryied通过子窗体执行查询,但无法成功。我更喜欢通过子表单来实现。子窗体的名称为:subUpdateOrder。 VB代码:
Current Status: I am able to attach Main forms data and generate mail but unable to attach subform's data as it only includes the first row, Tryied doing it through Subform and query both but no success. I will prefer to do it by subform itself. Subform's Name is : "subUpdateOrder". VB Code:
Private Sub InformCustomer_Click() On Error GoTo Err_InformCustomer_Click Dim CustName As String ' Customer Name Dim varTo As Variant '-- Address for SendObject Dim stText As String '-- E-mail text Dim DelDate As Variant '-- Rec date for e-mail text Dim stSubject As String '-- Subject line of e-mail Dim stOrderID As String '-- The Order ID from form Dim detailQry As String 'Dim stHelpDesk As String '-- Person who assigned ticket 'Dim strSQL As String '-- Create SQL update statement 'Dim errLoop As Error CstName = Me![CustName] varTo = Me![CustEmail] stSubject = ":: Update - Oder Status ::" stOrderID = Me.[OdrID] DelDate = Me.[OdrDeliveryDate] stText = "Dear" & CstName & _ "You have been assigned a new ticket." & Chr$(13) & Chr$(13) & _ "Order Number: " & stOrderID & Chr$(13) & _ "Please refer to your order status " & Chr$(13) & _ "Exp Delevery Date: " & DelDate & Chr$(13) & Chr$(13) & _ dQuery & Chr$(13) & _ "This is an automated message. Please do not respond to this e-mail." 'Write the e-mail content for sending to assignee DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, True Err_InformCustomer_Click: MsgBox Err.Description End SubForm Img: Form和Command1按钮运行代码
Form Img: Form and Command1 button to run the code
推荐答案它会像(在 CstName = Me![CustName] 之前插入):
It would be something like (to insert before CstName = Me![CustName]):
Dim dQuery As String Dim rs As DAO.Recordset Set rs = Me!NameOfYourSubformCONTROL.Form.RecordsetClone While Not rs.EOF dQuery = dQuery & rs![Brand Name].Value & vbTab & rs![Model Name].Value & vbTab & rs![Color].Value & vbCrLF Wend Set rs = Nothing更多推荐
在邮件正文中附加访问表单和子表单数据
发布评论