Passing variable to Access from Excel

NikToo

Board Regular
Joined
Sep 24, 2015
Messages
66
Office Version
  1. 365
Is it even possible to pass a variable from Excel to Access? I have a report which has the source directory for all the files in cell M5, I then need to run a query in Access which needs to pick up this source directory in order to open and save all the files. I thought maybe declaring it as Public would work but somehow I doubt it's that easy. The Access macro is run with a simple .run command.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Yes it is

You need to create a connection to Access using e.g. ADODB. You then use SQL to pass data to and from Access. You can do this in VBA, but the code will be unfamiliar to you - there's a useful free download at Case studies & example files - Spreadsheet Wizard Ltd which contains all the code you need to connect and read/write data

Thanks. I've downloaded it and had a look. I don't fully understand how it works but it looks like it actually writes data into the database. All I need is to pass a variable with a directory to it. Not sure if I can see a method for doing that in the code.
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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