Change query parameter with vbscript

juneau730

Board Regular
Joined
Jun 7, 2018
Messages
111
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
 
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.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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