访问 VBA 以获取 table 内容作为导出文件路径

Access VBA for table content as export file Path

我正在使用下面的代码将 PDF 格式的表单输出到文件夹 :\Completions Tracker\Drawings 并且工作正常,但我想将文件路径设置为引用 table,因此它可以由管理员在不同的项目中进行更改,而不必每次都更改 VBA 代码。

我想更改固定文件路径字符串以引用 table 数据而不是 [SettingDrawingFilePathTbl]![Drawing_FilePath].text 但是当我更改代码时我得到了调试,任何帮助都会很棒

Private Sub Command170_Click()
'------Print RFIRegisterInputF form, save input data and close form---------

DoCmd.OutputTo acOutputForm, "RFIRegisterInputF", acFormatPDF, "E:\Completions Tracker\Drawings" & [Forms]![RFIRegisterInputF]![Query_ID] & Format(Date, "ddmmyy") & ".pdf", True

DoCmd.Close acForm, "RFIRegisterInputF", acSaveYes

用一个table来保存文件名(ObjectName)和对应的路径:

Private Sub Command170_Click()

    '------Print RFIRegisterInputF form, save input data and close form---------
    Const ObjectName As String = "RFIRegisterInputF"

    Dim OutputFile As String

    OutputFile = DLookup("[Path]", "[TableName]", "ObjectName = '" & ObjectName & "'") & _
        [Forms]![RFIRegisterInputF]![Query_ID] & Format(Date, "ddmmyy") & ".pdf"

    DoCmd.OutputTo acOutputForm, ObjectName, acFormatPDF, OutputFile, True
    DoCmd.Close acForm, ObjectName, acSaveYes