Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

I need a VBA routine to add data to a field in a table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulc - 18 Jan 2006 18:05 GMT
Using Access 2003.

I'm using the following code to invoke a the comon open dialogue box in my
form.
The user selects a file and the file path is captured in the string
strInputFileName
I need the captured path and file name to be added to the table
'Con_DocPath' in the field 'DocumentPath'.

Unfortunately, i'm only part way there and i'm looking for some guidance

The file path is captured but i need a solution that places the captured
'strInputFileName' in the table.

Each time the user repeats the above, the new file path is added to a list
box on the form showing the selection and addition was successful.

on click sub...

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...", _
               Flags:=ahtOFN_HIDEREADONLY)

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

Many thanks.

Paul.
John Spencer - 18 Jan 2006 21:28 GMT
I'm not quite sure of everything you are doing, but you are not surrounding
your strInputFileName with quotes.  That will cause and error.

strSQL = "INSERT INTO Con_DocPath (DocumentPath) "
strSQL = strSQL & "VALUES(""" & strInputFileName & """);"

My preference is to use
strSQL = "INSERT INTO Con_DocPath (DocumentPath) "
strSQL = strSQL & "VALUES(" & Chr(34)  & strInputFileName & Chr(34) & ");"

That is always clearer to me.

> Using Access 2003.
>
[quoted text clipped - 32 lines]
>
> Paul.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.