#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default excel - sql

hi guys

Need help. This is my problem.
I would like to work in excel with data from MS Access. So I write macro,
use Microsoft Query etc. Everything works OK, but I'd like to have
possibility to change the data range from cells of excel. What I mean...

Below is a example of SQL query:

SELECT CALKOWITE.DATA, CALKOWITE.CZAS_PRACY_CALK,
CALKOWITE.CZAS_POSTOJU_CALK, CALKOWITE.DET
FROM `C:\Dynamics\COBRA\daneM1`.CALKOWITE CALKOWITE
WHERE (CALKOWITE.DATA={ts '2006-02-22 06:59:30'})
ORDER BY CALKOWITE.DATA

In section WHERE I have to write specific data (in this case - date)
Is there a possibility that I could use there one cell from excel?
I tried insert something like this:
'"Range("B1").Value"'
or
&Cells(3, 6).Value&

It does not work

Please help.

Thank you in advance

roody


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default excel - sql

You can do it, you just need to make sure the SQL result stays the same

so for example

SELECT AgeBal.DateOn FROM AgeBal WHERE (((AgeBal.DateOn)#5/1/2006#));

is a valid SQL string - using the date from the spreadsheet would give
something like
MySQL="SELECT AgeBal.DateOn FROM AgeBal WHERE (((AgeBal.DateOn)#" &
format(range("B1").value,"m/d/yyyy") & "#));"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default excel - sql

roody,
Check the Excel Help for "parameter_query".

NickHK

"roody" wrote in message
...
hi guys

Need help. This is my problem.
I would like to work in excel with data from MS Access. So I write macro,
use Microsoft Query etc. Everything works OK, but I'd like to have
possibility to change the data range from cells of excel. What I mean...

Below is a example of SQL query:

SELECT CALKOWITE.DATA, CALKOWITE.CZAS_PRACY_CALK,
CALKOWITE.CZAS_POSTOJU_CALK, CALKOWITE.DET
FROM `C:\Dynamics\COBRA\daneM1`.CALKOWITE CALKOWITE
WHERE (CALKOWITE.DATA={ts '2006-02-22 06:59:30'})
ORDER BY CALKOWITE.DATA

In section WHERE I have to write specific data (in this case - date)
Is there a possibility that I could use there one cell from excel?
I tried insert something like this:
'"Range("B1").Value"'
or
&Cells(3, 6).Value&

It does not work

Please help.

Thank you in advance

roody




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default excel - sql

It works!

thank you very, very much

roody

Uzytkownik napisal w wiadomosci
ups.com...
You can do it, you just need to make sure the SQL result stays the same

so for example

SELECT AgeBal.DateOn FROM AgeBal WHERE (((AgeBal.DateOn)#5/1/2006#));

is a valid SQL string - using the date from the spreadsheet would give
something like
MySQL="SELECT AgeBal.DateOn FROM AgeBal WHERE (((AgeBal.DateOn)#" &
format(range("B1").value,"m/d/yyyy") & "#));"



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default excel - sql

try with this:
Dim d As Date

d = Range("A1").Value

Dim strDate As String

'If your sql engine support this type of string date '2006-10-28 00:00:00'

strDate = DatePart("yyyy", d) & "-" & DatePart("m", d) & "-" & _
DatePart("d", d) & " " & DatePart("h", d) & ":" & DatePart("n", d) & ":" & _
DatePart("s", d)

'Then you can use strDate as parameter

Cecco (ITA)

"roody" wrote:

hi guys

Need help. This is my problem.
I would like to work in excel with data from MS Access. So I write macro,
use Microsoft Query etc. Everything works OK, but I'd like to have
possibility to change the data range from cells of excel. What I mean...

Below is a example of SQL query:

SELECT CALKOWITE.DATA, CALKOWITE.CZAS_PRACY_CALK,
CALKOWITE.CZAS_POSTOJU_CALK, CALKOWITE.DET
FROM `C:\Dynamics\COBRA\daneM1`.CALKOWITE CALKOWITE
WHERE (CALKOWITE.DATA={ts '2006-02-22 06:59:30'})
ORDER BY CALKOWITE.DATA

In section WHERE I have to write specific data (in this case - date)
Is there a possibility that I could use there one cell from excel?
I tried insert something like this:
'"Range("B1").Value"'
or
&Cells(3, 6).Value&

It does not work

Please help.

Thank you in advance

roody



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



All times are GMT +1. The time now is 12:19 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"