0

为什么这不起作用!?!显然我的数据库找不到您的表达式中提到的字段“”。?签名,相当沮丧-ps。

Private Sub Command17_Click()
On Error GoTo Err_Command17_Click

Dim rst As DAO.Recordset
Dim strEmailAddress

Set rst = CurrentDb.OpenRecordset([CourseRosterMaterialsEmail_Query])

Do Until rst.EOF
  strEmailAddress = strEmailAddress & rst([CourseRosterMaterialsEmail_Query].[Email]) & ";"
  rst.MoveNext
Loop

strEmailAddress = Left(strEmailAddress, Len(strEmailAddress) - 1)

DoCmd.SendObject , , acFormatRTF, strEmailAddress, _
, , [CourseTitle], [Forms]![CourseRosterMaterials_Form]![Details], False, False

rst.Close
Set rst = Nothing

Exit_Command17_Click:
    Exit Sub

Err_Command17_Click:
    MsgBox Err.Description
    Resume Exit_Command17_Click

End Sub
4

1 回答 1

0

尝试这个:

Private Sub Command17_Click()
    On Error GoTo Err_Command17_Click

    Dim rst As DAO.Recordset
    Dim strEmailAddress

    Set rst = CurrentDb.OpenRecordset([CourseRosterMaterialsEmail_Query])

    Do Until rst.EOF
      strEmailAddress = strEmailAddress & rst("Email") & ";"
      rst.MoveNext
    Loop

    strEmailAddress = Left(strEmailAddress, Len(strEmailAddress) - 1)

    DoCmd.SendObject , , acFormatRTF, strEmailAddress, _
    , , [CourseTitle], [Forms]![CourseRosterMaterials_Form]![Details], False, False

    rst.Close
    Set rst = Nothing

    Exit_Command17_Click:
        Exit Sub

    Err_Command17_Click:
        MsgBox Err.Description
        Resume Exit_Command17_Click

End Sub

通常要引用 Recordsets 中的字段,您需要这样做:

rst("FieldName") 'May be ambiguous
rst("FieldAliasName") 'Only if you use aliases
rst("tablename.fieldname") 'I'm actually not sure if this always works
rst("[field name]") 'Use brackets for tables with spaces, symbols, or reserved words
于 2013-09-11T17:29:41.633 回答