Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 12
Default select fields names with "dot"

How to select field names which contain a dot "."?
Error comes out when running the following codes, i guess it is caused by
the field name "ship.date"
Would you pls advise...
Thanks a lot!!

______________________________________________

Sub getFields()

Dim varConn2, varSql2 As String
Dim varQry2 As QueryTable

varConn2 = "ODBC;DefaultDir=c:\Test;driver={Microsoft Excel Driver
(*.xls)};DriverId=790;dbq=c:\Test\table1.xls"

varSql2 = "SELECT PRODUCT, [Unit Price] as UNIT_PRICE, ship.date, sum([Open
Qty]) as SUM_OPEN_QTY from [Raw$] group by Product, [Unit Price], ship.date"

Set varQry2 = Worksheets("test").QueryTables.Add(Connection:=var Conn2,
Destination:=Worksheets("test").Range("a1"), Sql:=varSql2)

Worksheets("test").Range("A:IV").ClearContents

varQry2.BackgroundQuery = False
varQry2.Refresh

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default select fields names with "dot"

Try putting square brackets around ship.date, as in [ship.date]

Bob

"guy" wrote:

How to select field names which contain a dot "."?
Error comes out when running the following codes, i guess it is caused by
the field name "ship.date"
Would you pls advise...
Thanks a lot!!

______________________________________________

Sub getFields()

Dim varConn2, varSql2 As String
Dim varQry2 As QueryTable

varConn2 = "ODBC;DefaultDir=c:\Test;driver={Microsoft Excel Driver
(*.xls)};DriverId=790;dbq=c:\Test\table1.xls"

varSql2 = "SELECT PRODUCT, [Unit Price] as UNIT_PRICE, ship.date, sum([Open
Qty]) as SUM_OPEN_QTY from [Raw$] group by Product, [Unit Price], ship.date"

Set varQry2 = Worksheets("test").QueryTables.Add(Connection:=var Conn2,
Destination:=Worksheets("test").Range("a1"), Sql:=varSql2)

Worksheets("test").Range("A:IV").ClearContents

varQry2.BackgroundQuery = False
varQry2.Refresh

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 12
Default select fields names with "dot"

still failed...

"INTP56" ...
Try putting square brackets around ship.date, as in [ship.date]

Bob

"guy" wrote:

How to select field names which contain a dot "."?
Error comes out when running the following codes, i guess it is caused by
the field name "ship.date"
Would you pls advise...
Thanks a lot!!

______________________________________________

Sub getFields()

Dim varConn2, varSql2 As String
Dim varQry2 As QueryTable

varConn2 = "ODBC;DefaultDir=c:\Test;driver={Microsoft Excel Driver
(*.xls)};DriverId=790;dbq=c:\Test\table1.xls"

varSql2 = "SELECT PRODUCT, [Unit Price] as UNIT_PRICE, ship.date,
sum([Open
Qty]) as SUM_OPEN_QTY from [Raw$] group by Product, [Unit Price],
ship.date"

Set varQry2 = Worksheets("test").QueryTables.Add(Connection:=var Conn2,
Destination:=Worksheets("test").Range("a1"), Sql:=varSql2)

Worksheets("test").Range("A:IV").ClearContents

varQry2.BackgroundQuery = False
varQry2.Refresh

End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default select fields names with "dot"

I thought the [] might help, but since they don't I'm not sure there is an
answer, other than you have to get the dot out of any column you want to use
in a SQL statement, because "." is used to qualify objects, as in
Database.Schema.Table.Column.

Bob

"guy" wrote:

still failed...

"INTP56" ...
Try putting square brackets around ship.date, as in [ship.date]

Bob

"guy" wrote:

How to select field names which contain a dot "."?
Error comes out when running the following codes, i guess it is caused by
the field name "ship.date"
Would you pls advise...
Thanks a lot!!

______________________________________________

Sub getFields()

Dim varConn2, varSql2 As String
Dim varQry2 As QueryTable

varConn2 = "ODBC;DefaultDir=c:\Test;driver={Microsoft Excel Driver
(*.xls)};DriverId=790;dbq=c:\Test\table1.xls"

varSql2 = "SELECT PRODUCT, [Unit Price] as UNIT_PRICE, ship.date,
sum([Open
Qty]) as SUM_OPEN_QTY from [Raw$] group by Product, [Unit Price],
ship.date"

Set varQry2 = Worksheets("test").QueryTables.Add(Connection:=var Conn2,
Destination:=Worksheets("test").Range("a1"), Sql:=varSql2)

Worksheets("test").Range("A:IV").ClearContents

varQry2.BackgroundQuery = False
varQry2.Refresh

End Sub






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do you select many fields in a pivot table to drag in "data"? Gg Excel Discussion (Misc queries) 0 December 16th 09 05:06 PM
"Control" plus "click" doesn't allow me to select multiple cells Ken Cooke New Users to Excel 0 September 25th 06 04:46 PM
Backup to specific folder if workbook names begins with "NSR" or "MAC" GregR Excel Programming 3 May 6th 05 12:24 AM
insert/names/apply - how to "select all" ? Wild Bill[_2_] Excel Programming 1 May 1st 05 10:45 AM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"