Vba 将变量中的数据存储到表中的字段中

Vba 将变量中的数据存储到表中的字段中,vba,ms-access,Vba,Ms Access,所以我在Access中有一个子项,它根据用户名创建一个文件夹,但我想知道的是,如何将文件路径保存到表中的字段中 这是我的代码,我想将strFolder保存到表table\u Users Private Sub btnSaveClose_Click() Const strParent = "\\dlreng01\Roberts$\Access\Images\" Dim struserID As String Dim strFolder As String Dim fso As Object ' G

所以我在Access中有一个子项,它根据用户名创建一个文件夹,但我想知道的是,如何将文件路径保存到表中的字段中

这是我的代码,我想将
strFolder
保存到表
table\u Users

Private Sub btnSaveClose_Click()
Const strParent = "\\dlreng01\Roberts$\Access\Images\"
Dim struserID As String
Dim strFolder As String
Dim fso As Object
' Get user ID from control
struserID = Me.UserName
' Full path
strFolder = strParent & struserID
' Create FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
' Check whether folder exists
If fso.FolderExists(strFolder) = False Then
    ' If not, create it
    fso.CreateFolder strFolder
End If
' Open it
Shell "explorer.exe " & strFolder, vbNormalFocus
End Sub
一种方法是:

Public Sub Test()

    AddFilePath "MyFilePath"  'strParent & struserID

End Sub

Public Sub AddFilePath(strFolder As String)

    Dim rst As DAO.Recordset

    Set rst = CurrentDb.OpenRecordset("Table_Users", dbOpenDynaset)
    With rst
        .AddNew
        .Fields("ImageFilePath") = strFolder
        .Update
        .Close
    End With

    Set rst = Nothing

End Sub

我一定是做错了什么,因为我不能让这个函数工作,代码执行并且没有错误,但是它没有将文件路径复制到字段中,我已经将这两个函数都放入了相关的VBA表单中。