View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
joel[_286_] joel[_286_] is offline
external usenet poster
 
Posts: 1
Default Excel VBA SQL Query Filename


the tilda character microsoft started in window 95 using in a file name
so the DOS commands could work in the windows environment. Filenames
and folders were given a short 8 character name and a window name so the
DOs commands would stilloperate. If a filename was


abcdefghijkl.xls

the full name was the window name and the DOs name would be
abcdef~1.xls

A second file was given the name

abcdefghijkm.xls
abcdef~2.xls


I started look at you SQL and think there are more changes required

From
FileName = Range("cnp_source").Value
FileName = Replace(FileName, ".dbf", "")

To
FileName = Range("cnp_source").Value
FileName = Replace(FileName, ".dbf", "")
FileName = chr(39) & FileName & chr(39) 'put single quotes around
filename



Or this

From
SQLQuery = "SELECT *" & vbcrlf & "FROM " &
FileName & " " & FileName & "" & vbcrlf & "WHERE " &
FileName & ".time = ' 0'" & vbcrlf & "ORDER BY
" & FileName & ".product, " & FileName & ".purpose, " & FileName &
".group"
to
SQLQuery = "SELECT *" & vbcrlf & "FROM " & _
chr(39) & FileName & chr(39) & " " & _
chr(39) & FileName & chr(39) & vbcrlf & "WHERE " & _
chr(39) & FileName & ".time" & chr(39) & "= ' 0'" & vbcrlf & "ORDER
BY " & _
chr(39) & FileName & ".product" & chr(39) & ", " & _
chr(39) & FileName & ".purpose" & chr(39) & ", " & _
chr(39) & FileName & ".group" & chr(39)


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=158796

Microsoft Office Help