Saving a file path in a table record

G

Guest

I'm using MS Access 2003

I looking for a solution that allows a user to select a file using the
CommonFileOpenSave dialogue box, then save the full path and name of that
file as a hyperlink into a table.

The following allows the user to pick the file and capture the full path in
a string variable: strInputFileName. This part works.

I need access to then place the string into a filed called DocumentPath in
the table Con_DocPath. I thought the last 3 lines of the routine would
achieve this but it does not.

The user can continue to add as many file paths as required, by repeating
this routine.

Can anyone help me resolve this?

Thanks, Paul

Dim strFilter As String
Dim strInputFileName As String
Dim strSQL As String

'strFilter = ahtAddFilterItem(strFilter, "Word Files (*.doc)", "*.doc")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select the documents associated with
this contract...", _
Flags:=ahtOFN_HIDEREADONLY)


strSQL = "INSERT INTO Con_DocPath (DocumentPath) "
strSQL = strSQL & "VALUES(" & strInputFileName & " );"
CurrentDb.Execute strSQL
 
G

Guest

As you are inserting a string variable into your table it has to be wrapped
in quotes in your insert statement:

strSQL = strSQL & "VALUES ('" & strInputFileName & "');"

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top