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