![]() |
Syntax for Excel variable using a SQL Select/From/Where Command...
Mark,
Try something like the following: Dim SQL As String SQL = "SELECT tblStoreList.`Store Name` " & _ " FROM `\\RT-Admin\Adminshare\Robert\Setup`.tblStoreList tblStoreList " & _ "WHERE (tblStoreList.`Store #`=" & Range("A1").Text & ")" -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Mark D." <Mark wrote in message ... What is the proper syntax for using the contents of an Excel cell in an SQL Select/From/Where command. I'm trying to do a table lookup look-up in an Access DB from Excel based on the value of the contents in an Excel cell. Here is my statement. SELECT tblStoreList.`Store Name` FROM `\\RT-Admin\Adminshare\Robert\Setup`.tblStoreList tblStoreList WHERE (tblStoreList.`Store #`=?????) I can't seem to get the right syntax for referencing cell B6 at the end of the statement. Both the cell and the Access table field are numeric. I started out using MS Query and put a specific value in the statement. Then tried to modify the SQL to reference a cell. Any suggestions? |
All times are GMT +1. The time now is 05:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com