Can This Be Done in Access?

  • Thread starter Thread starter Mark S via AccessMonster.com
  • Start date Start date
M

Mark S via AccessMonster.com

I have 5 different locations (sites) we'll call A, B, C, D, E. The location
is used in all my queries. I have 5 different command buttons that when I
click on one it takes the user to a form with information pertaining to that
location. Example: Click on command button A takes user to location A.
Instead of writing 5 different queries for each location, is there a way to
pass the location to the query once the command button is clicked?

Obviously I am a newbie at this and any help is appreciated.
 
If you're using the query QBE wizard, add something like the following to
the criteria box:

[Enter the location]

Make sure you include the square brackets. The SQL for the final query might
look something like:

Select * From tblLocations Where Location=[Enter the location];
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
You might want to consider a combobox or listbox that lets you select one of
the five sites and then you can just have one button that sends you to the
right place. Instead of putting [Enter Location] in the criteria box, you
would put:
forms!YourForm.NameOfYourCombobox
Just something to think about if you want to do some studying
 
And then the next step will probably be....

Have the source of the combo box be a query of that table of
information getting only the site names with a "Select distinct
sitename from table" (you have to add distinct manually if you use the
query wizard to create the query.) That way when they add the 3 new
sites that no one tells you about you don't have to change any code. It
will get them automatically. If the table is very large this may not be
a good way.

The next best way is to have a small table of just the allowable sites
and have the query use this (but also have any new input restrict the
site to only those in the table.) If you do not limit the input to the
allowed then misspellings of a site name will NOT be found (except with
the distinct option).

Just things to think about as they begin to use your system.

Ron
 
Back
Top