MS Access Run-time Error 3162 -
i'm trying use code copy file new folder , add file path/name docname column in tblfileattachments.
when select file add, keep getting error "run-time error 3162...you tried assign null value variable not variant data type."
here tables have
tblfileattachments - docid - docname - requestid_fk tblrequests - requestid - pfname - plname - pbusinessname
i have form based on tblfileattachments docid, docname , requestid_fk fields. have "add file" button following code:
private sub btnattachfile_click() dim rsfile dao.recordset dim strfilepath string, strfilename string strfilepath = fselectfile() if strfilepath & "" <> "" strfilename = mid(strfilepath, instrrev(strfilepath, "\") + 1) currentdb.openrecordset("tblfileattachments") .addnew !docid = me.docid !filepath = strfilepath !filename = strfilename .update end end if end sub
debugging error, highlights
!docid = me.docid
docid
autonumber column?
then don't assign @ while creating new record, leave out line:
!docid = me.docid
the id generated automatically.
Comments
Post a Comment