Help to Exclude Records SQL

  • Thread starter Thread starter rebelscum0000
  • Start date Start date
R

rebelscum0000

Dear all

I have 2 Tbl's one Called Search_Tlb & Documents_Settings_Tbl with the
same fields

In the tbls I have a field called FolderPath, with these records:

C:\Documents and Settings\All Users\Start Menu\Programs\
C:\Documents and Settings\Administrador\Desktop\
C:\Program Files\
C:\Program Files\Common Files\

I do not want to have all that kind of records (appended Query) into my
Tbl Documents_Settings
I need to exclude them from my SQL Statement but I do not have any idea
how to do this

strSQL = _
"INSERT INTO Documents_Settings_Tbl ( ID, Keyword, " & _
"Appz, FileName, FolderPath, Extension, FileType, " & _
"FileSize, Modified, Accessed, Created, Attributes, Include ) " & _
"SELECT Search_Tlb.ID, Search_Tlb.Keyword, Search_Tlb.Appz, " & _
"Search_Tlb.FileName, Search_Tlb.FolderPath, Search_Tlb.Extension, " &
_
"Search_Tlb.FileType, Search_Tlb.FileSize, Search_Tlb.Modified, " & _
"Search_Tlb.Accessed, Search_Tlb.Created, Search_Tlb.Attributes, " & _
"Search_Tlb.Include " & _
"FROM Search_Tlb; " '& _
'"WHERE (((IIf(Left(Folder Path,16))='C:\Program Files'))); " <-MY
Problem

CurrentDb.Execute strSQL, dbFailOnError



Please help me!!

Thanks in advance

Regards
Antonio Macias
 
You have Folder space Path in the code you posted in the where clause. Also, I
would use a like comparision operator in the WHERE Caluse

strSQL = _
"INSERT INTO Documents_Settings_Tbl ( ID, Keyword, " & _
"Appz, FileName, FolderPath, Extension, FileType, " & _
"FileSize, Modified, Accessed, Created, Attributes, Include ) " & _
"SELECT Search_Tlb.ID, Search_Tlb.Keyword, Search_Tlb.Appz, " & _
"Search_Tlb.FileName, Search_Tlb.FolderPath, Search_Tlb.Extension, " &
_
"Search_Tlb.FileType, Search_Tlb.FileSize, Search_Tlb.Modified, " & _
"Search_Tlb.Accessed, Search_Tlb.Created, Search_Tlb.Attributes, " & _
"Search_Tlb.Include " & _
"FROM Search_Tlb " & _
'"WHERE [Folder Path] Like 'C:\Program Files*"

'Instead of executing the query, try adding a debug.print statement
'and copy the SQL string to a blank query and see if it runs.
'The error message you will get it it fails will usually be clearer.
'Once the query is running correctly, then you can get rid of the
'debug code.

Debug.Print strSQL
STOP

CurrentDb.Execute strSQL, dbFailOnError
 
Thank you very much!

It works

"WHERE FolderPath Like 'C:\Documents and Settings*'"

Regards,
Antonio Macias
 
Back
Top