Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel, reference a cell for parameter in SQL to import data

I am using SQL in Microsoft Query to import data from a ODBC data source
into Excel. I am linking mutiple tables from the source and this seems
to prevent from being able to reference a cell in the spreadsheet as a
parameter value. The import works when I 'hard-code' the date in the
code, but I would like to be able to reference a cell in the spreadsheet
so the end user can refresh the data after just changing the date in the
spreadsheet. Here's a portion of my code:

SELECT trim(gltrans.ref), GlTrans.Value
FROM GlTrans INNER JOIN SYSFIL
ON (GlTrans.SUB_ACCT = SYSFIL.DB_SUB_ACCT)
AND (GlTrans.ACCT = SYSFIL.DB_ACCT)
AND (GlTrans.DEPT = SYSFIL.DB_DEPT)
AND (GlTrans.BRANCH = SYSFIL.DB_BRANCH)
AND (GlTrans.COY = SYSFIL.DB_COY)
WHERE GlTrans.Period_Date < '2006-06-01' AND
(SYSFIL.Module_Type='VHS' AND SYSFIL.Acc_des='RT') AND
GlTrans.Year_End_Date =
(SELECT current_year_end_date FROM company WHERE coy = (SELECT db_coy
FROM sysfil WHERE acc_des = 'debtor'));

What I would like to do is replace the '2006-06-01' date with the date
supplied in cell C1 in my spreadsheet. I do have the date formatted
correctly in the cell.

I have searched for resolutions on the Internet, trying several
examples, but have not found the correct resolution yet. Any help is
appreciated.
Brian
Business Analyst
JDIS

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Excel, reference a cell for parameter in SQL to import data

Use square brackets in thew statement. When you refresh the table, it
will prompt you for a value and give you the option to select a range
and save it (or a value) in the query.

WHERE GlTrans.Period_Date < [ ]

You can also edit parameters from the data menu - Dat,Import External
Data, Paramaters.

If you are using the visual interface to create queries you can enter
the square brackets in the dialog box as the value when you're choosing
criteria.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Excel, reference a cell for parameter in SQL to import data


Sorry - in the actual sql statement, use a question mark:

WHERE
((X.X_DATE=?)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Excel, reference a cell for parameter in SQL to import data


WHERE (GlTrans.Period_Date < ?)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel, reference a cell for parameter in SQL to import data

Thanks for your suggestions, but I continue to get errors...
When I put "WHERE (GlTrans.Period_Date < ?)" I get the error message
"Parameters are not allowed in queries that can't be displayed
graphically".
If I put the questionmark in single quotes I get an error message
"Cannot convert ? to a time stamp".
If in double quotes I get a "Column '?' not found error.

Any other thoughts?
Brian
Business Analyst
JDIS

*** Sent via Developersdex http://www.developersdex.com ***
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
import data from an Access parameter query PluckyMo Excel Discussion (Misc queries) 2 April 12th 06 04:42 AM
Data_field parameter in getpivotdtata as a cell reference. Tomas Excel Discussion (Misc queries) 1 July 22nd 05 03:18 AM
Help to import data from reference workbook JackSpam Excel Discussion (Misc queries) 2 July 20th 05 02:37 AM
Data Import Cell Reference John Excel Programming 6 December 31st 04 08:15 PM
Import Access records to excel (parameter is a called funct) v.20 PSKelligan Excel Programming 18 September 28th 04 03:03 PM


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

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"