MS Access 2010 - Variables (Declare/Set)

vsummers

New Member
Joined
Jan 27, 2003
Messages
40
I am working with MS Access 2010 and hoping to, as I would using SQL Server, declare and set variables within a query. Does MS Access support this? If so what is the syntax?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi, you can use the Pass-Through query. In my case, Mikel ERP, take advantage of everything related to the environment in MySQL, SQL Server, PostgreSQL. But in most cases, I use stored procedures from VBA
 
Upvote 0
MSAccess SQL doesn't directly support declare or set with variables. By which I mean you cannot write SQL queries with DECLARE and SET and run them.

However, You can use MSAccess VBA to combine visual basic programming elements (variables) and manipulate them in conjunction with SQL queries. This will be clunky compared to TSQL but will get the job done if you really need this kind of behavior and can't work around it with plain SQL or SQL parameters.

As stated above, if you use a pass-through query to pass through the sql to a server such as SQL Server, then you can write the query exactly as it would be executed on SQL server - in the case Access isn't executing the query but the remote server is doing the execution so you can leverage the features available on the remote server.
 
Upvote 0

Forum statistics

Threads
1,221,547
Messages
6,160,456
Members
451,647
Latest member
Tdeulkar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top