0
我试图用这个代码将文件复制到一个新的文件夹和文件路径/名tblFileAttachments添加到柱可采用DocName。MS Access运行时错误3162
当我选择要添加的文件,我不断收到此错误“运行时错误3162 ...你试图NULL值赋值给一个变量是不是Variant数据类型。”
下面是表我有
tblFileAttachments
- DocID
- DocName
- RequestID_FK
tblRequests
- RequestID
- PFName
- PLName
- PBusinessName
我基于与的DocID,并且可采用DocName领域RequestID_FK一个tblFileAttachments形式。我也有下面的代码“添加文件”按钮:
Private Sub btnAttachFile_Click()
Dim rsFile As DAO.Recordset
Dim strFilePath As String, strFilename As String
strFilePath = fSelectFile()
If strFilePath & "" <> "" Then
strFilename = Mid(strFilePath, InStrRev(strFilePath, "\") + 1)
With CurrentDb.OpenRecordset("tblFileAttachments")
.AddNew
!DocID = Me.DocID
!FilePath = strFilePath
!FileName = strFilename
.Update
End With
End If
End Sub
调试错误,它突出
!DocID = Me.DocID