Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Insert into...Values" with strings 1

Status
Not open for further replies.

CharlesFS

Technical User
Dec 14, 2008
39
BR
Hi!, i can not insert 3 strings values in 3 table fields! I think the fault is the string "strDOCfile = f.Name" because his value is a file name like "file.DOC" and i have operator error on debugger.

Code:
Sub EBA()
Dim fs, f, s
Dim SourceDir As String 'The source directory
Dim ArqExiste As Boolean
Dim file As String
Dim CODCVM As String
Dim BUSCACODCVM As Variant
Dim DATAITR As String
Dim BUSCADATAITR As Variant
SourceDir = "C:\"   'Diretorio onde estao os .DOC
Set fs = CreateObject("Scripting.FileSystemObject")
Set folder = fs.GetFolder(SourceDir)
For Each f In folder.files
 If Mid(f.Name, Len(f.Name) - 3) = ".DOC" Then
 
 strEmp = "5410"
 strDate = "1012008"
 file = SourceDir & f.Name
 strDOCfile = f.Name
 
 ArqExiste = FileExists(file)
 If ArqExiste = True Then

Dim sSQL As String
Dim dbs As Database
Set dbs = CurrentDb()
[b]
 sSQL = "Insert Into DOC(CODemp,DOCdate,File) Values ('" & strEmp & "' , " & strDate & ", " & strDOCfile & ") "
[/b]
dbs.Execute sSQL
End If
End If
Next
End Sub
 
You must use single quote delimiters for text fields:

sSQL = "Insert Into DOC(CODemp,DOCdate,File) Values ('" & strEmp & "' , '" & strDate & "', '" & strDOCfile & "') "

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top