Change query parameter with vbscript

juneau730

Board Regular
Joined
Jun 7, 2018
Messages
80
I've searched the wonderful world of Google for a simple answer and wasn't able to find one.

Is there a simple way to have a standalone (manually executed) vbscript to change an Access query parameters?

I have the same parameter in three queries, which is Like"XXX"

I need to replace the XXX with a manually input three letter code
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,950
Office Version
  1. 365
Platform
  1. Windows
OK, here is what you do.

In our one record "Settings" table, we will have a location specific field (let's call it "Site_Code") where we enter the values, like "PHO" for your example.
Then, add this table in to your query where you are pulling all the information, but do NOT create a join between this Settings table and the main data table.
Then, in the criteria row under the "NT Name" field, we would enter:
Code:
Like "*" & [Settings]![Site_Code] & "*"
and that should filter the the records the way you want.

So all each location would need to do is to set the "Site Code" field value on the Main Form, and it should propagate to the queries and do what you want.
Like I said, I often use the "Settings" table as the source of my Startup Form, so it is easily accessible/seen.
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,950
Office Version
  1. 365
Platform
  1. Windows
You are welcome!
:)
 

stumac

Active Member
Joined
Jul 16, 2010
Messages
471
I would recommend using more than the 3 letter site code if possible:

Imagine you get a new use John Phelps working in the PHO site - they would then appear in both the ELP and the PHO query.If the VHA is always there then include that.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,975
Messages
5,599,127
Members
414,291
Latest member
yanqing06

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
Top