Skip to main content
Question

SQL From statement as a variable

  • April 12, 2023
  • 2 replies
  • 268 views

Forum|alt.badge.img+1

Hello Everyone 

Usually the statement is like: Select * from [sheet1$$] where  etc etc

I need the sheet1 to be a variable, the sheet changes with each excell book I bring in and there are lots

I tried [$SheetNameHere$] that did not work, even when I remove the square brackets.

2 replies

rbkadiyam
Premier Pathfinder | Tier 7
Forum|alt.badge.img+17
  • Premier Pathfinder | Tier 7
  • April 12, 2023

@The Automator  what error you are getting ?


Forum|alt.badge.img+1
  • Author
  • Cadet | Tier 2
  • April 12, 2023

The Microsoft Access database engine could not find the object - after the word object in single quotes was the value of the variable then it goes on to say make sure the object exists.

The name it mentions is the correct sheet name, it does successfully open the spreadsheet.