ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't quite get this syntax to bring in the required information. (https://www.excelbanter.com/excel-programming/283893-cant-quite-get-syntax-bring-required-information.html)

Sharlene England

Can't quite get this syntax to bring in the required information.
 
I want to have the user type into cell A1 then the query will get the
correct information.

The following works:
"SELECT JOB_NO.CUSTCODE, JOB_NO.JOB_NO" & Chr(13) & "" & Chr(10) & "FROM
`K:\DATA\DBDATA\JOBDATA`\JOB_NO.DBF JOB_NO" & Chr(13) & "" & Chr(10) &
"WHERE (JOB_NO.JOB_NO=50068)")


but now I want to replace the 50068 above with a cell reference to the value
in cell A1.

I've tried and tried and can't get this to work.

Any help would be greatly appreciated.

Thanks.



Bill Manville

Can't quite get this syntax to bring in the required information.
 
Sharlene England wrote:
The following works:
"SELECT JOB_NO.CUSTCODE, JOB_NO.JOB_NO" & Chr(13) & "" & Chr(10) & "FROM
`K:\DATA\DBDATA\JOBDATA`\JOB_NO.DBF JOB_NO" & Chr(13) & "" & Chr(10) &
"WHERE (JOB_NO.JOB_NO=50068)")

but now I want to replace the 50068 above with a cell reference to the value
in cell A1.


"SELECT JOB_NO.CUSTCODE, JOB_NO.JOB_NO" & Chr(13) & "" & Chr(10) & _
"FROM `K:\DATA\DBDATA\JOBDATA`\JOB_NO.DBF JOB_NO" & _
Chr(13) & "" & Chr(10) & "WHERE (JOB_NO.JOB_NO=" & Range("A1") & ")"

In more recent versions of Excel you can give your query a "parameter" which
you can specify as coming from a range - and even have the query re-run
automatically when the value in the range changes. Select a cell in your
query results and try Data / Get External Data / Parameters

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup



All times are GMT +1. The time now is 09:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com