Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Refernce to cell in SQL statemen

Hi all,

I have a problem. I recorded Macro that conects to ODBC database and pulls
some data to Excel sheet. I would like that user puts date in a cell and
that this date is passed to query. My macro looks like this:

Sub Makronaredba1()

With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=DATMAX;ServerName=SERVER.1583;ServerDSN= DATMAX;ArrayFetchOn=1;ArrayBufferSize=8;TransportH int=TCP:SPX;DecimalSymbol=,;Clien"
_
),
Array("tVersion=8.50.189.000;CodePageConvert=1250; AutoDoubleQuote=0;")), _
Destination:=Range("A1"))
.CommandText = Array( _
"SELECT ""Transaction History"".PRTNUM_15, ""Transaction
History"".TNXDTE_15" & Chr(13) & "" & Chr(10) & "FROM ""Transaction
History"" ""Transaction History""" & Chr(13) & "" & Chr(10) & "WHERE
(""Transaction History"".TNXDTE_15={d '2006-05-04'} And ""Transaction His"
_
, _
"tory"".TNXDTE_15<={d '2009-01-01'})" & Chr(13) & "" & Chr(10) &
"ORDER BY ""Transaction History"".PRTNUM_15" _
)
.Name = "Query from DATMAX"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub

I would like to put cell reference in this part of code:

"WHERE (""Transaction History"".TNXDTE_15={d '2006-05-04'}

So that insted '2006-05-04' is something like Range(A1) or something like
this (also with reference to sheet).

I hope that someone can help me

Eewo


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Refernce to cell in SQL statemen

"WHERE
(""Transaction History"".TNXDTE_15={d '" & Format(Range("A1").value,
"yyyy-mm-dd") & "'} And ""Transaction His"


--
__________________________________
HTH

Bob

"Eewo" wrote in message
...
Hi all,

I have a problem. I recorded Macro that conects to ODBC database and pulls
some data to Excel sheet. I would like that user puts date in a cell and
that this date is passed to query. My macro looks like this:

Sub Makronaredba1()

With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _

"ODBC;DSN=DATMAX;ServerName=SERVER.1583;ServerDSN= DATMAX;ArrayFetchOn=1;ArrayBufferSize=8;TransportH int=TCP:SPX;DecimalSymbol=,;Clien"
_
),
Array("tVersion=8.50.189.000;CodePageConvert=1250; AutoDoubleQuote=0;")), _
Destination:=Range("A1"))
.CommandText = Array( _
"SELECT ""Transaction History"".PRTNUM_15, ""Transaction
History"".TNXDTE_15" & Chr(13) & "" & Chr(10) & "FROM ""Transaction
History"" ""Transaction History""" & Chr(13) & "" & Chr(10) & "WHERE
(""Transaction History"".TNXDTE_15={d '2006-05-04'} And ""Transaction
His" _
, _
"tory"".TNXDTE_15<={d '2009-01-01'})" & Chr(13) & "" & Chr(10) &
"ORDER BY ""Transaction History"".PRTNUM_15" _
)
.Name = "Query from DATMAX"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub

I would like to put cell reference in this part of code:

"WHERE (""Transaction History"".TNXDTE_15={d '2006-05-04'}

So that insted '2006-05-04' is something like Range(A1) or something like
this (also with reference to sheet).

I hope that someone can help me

Eewo



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
Absolute Cell refernce Not working DJ Harrington Excel Discussion (Misc queries) 9 February 9th 09 04:11 PM
Using IF to refernce another cell Hamed parhizkar Excel Programming 2 June 24th 08 06:39 PM
need 2 create refernce in formula thatpoints to cell in other tab Robb Excel Discussion (Misc queries) 2 May 30th 06 04:09 PM
Using absolute cell refernce and inserting rows ladyhawk Excel Worksheet Functions 10 December 13th 05 10:59 PM
How do I use a cell as a referance to a file in a lookup statemen. SarahP Excel Worksheet Functions 1 January 27th 05 11:09 PM


All times are GMT +1. The time now is 05:52 PM.

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

About Us

"It's about Microsoft Excel"