Using Variable in Where Clause

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have several forms that access the same table or queries based on the same
table, therefore with the same field names. I have the need to run a macro
with conditions that will open a form based on [FacilityNumber] on the new
form matching [FacilityNumber] on the currenly open form. I am using the
"Where" function of the "OpenForm" action to do this with the input of
[FacilityNumber]=[Forms]![NewWaste![FacilityNumber]
Since I need to do this same function from different forms is there anyway I
can reference the form name in the second part of the argument as a
variable, or the form that called the macro, without using VBA, in other
words within ACCESS itself?
Thanks for any help you can give.
 
GeorgieGirl said:
I have several forms that access the same table or queries based on
the same table, therefore with the same field names. I have the need
to run a macro with conditions that will open a form based on
[FacilityNumber] on the new form matching [FacilityNumber] on the
currenly open form. I am using the "Where" function of the
"OpenForm" action to do this with the input of
[FacilityNumber]=[Forms]![NewWaste![FacilityNumber]
Since I need to do this same function from different forms is there
anyway I can reference the form name in the second part of the
argument as a variable, or the form that called the macro, without
using VBA, in other words within ACCESS itself?
Thanks for any help you can give.

VBA is part of Access, probably more so than macros are.
Macros are a very poor substitute for VBA and offer essentially no error
control.
It is unlikely that you will be able to do what you want and if you can it
will be a very convoluted solution.

I can't get any handle on why you might have a bunch of different forms all
for the same table. It would seem that one form with pages or tabs would
handle it.
 
Mke,
Thanks for the answer even though it was not the one I was hoping for (but
kind of expected). The reason I am using different forms is that my
application has three distinct parts, but all have a common dependency on the
"FacilityTable". My forms, therefore. all have parts of the "Facility Table"
with subforms that are totally independent of one another.

I guess it is time to learn VBA. I have coded in my past life, but not in
any type of basic. Can you suggest a good book or online class to learn VBA?
I would sure appreciate it.

Deena

Mike Painter said:
GeorgieGirl said:
I have several forms that access the same table or queries based on
the same table, therefore with the same field names. I have the need
to run a macro with conditions that will open a form based on
[FacilityNumber] on the new form matching [FacilityNumber] on the
currenly open form. I am using the "Where" function of the
"OpenForm" action to do this with the input of
[FacilityNumber]=[Forms]![NewWaste![FacilityNumber]
Since I need to do this same function from different forms is there
anyway I can reference the form name in the second part of the
argument as a variable, or the form that called the macro, without
using VBA, in other words within ACCESS itself?
Thanks for any help you can give.

VBA is part of Access, probably more so than macros are.
Macros are a very poor substitute for VBA and offer essentially no error
control.
It is unlikely that you will be able to do what you want and if you can it
will be a very convoluted solution.

I can't get any handle on why you might have a bunch of different forms all
for the same table. It would seem that one form with pages or tabs would
handle it.
 
GeorgieGirl said:
Mke,
Thanks for the answer even though it was not the one I was hoping for
(but kind of expected). The reason I am using different forms is
that my application has three distinct parts, but all have a common
dependency on the "FacilityTable". My forms, therefore. all have
parts of the "Facility Table" with subforms that are totally
independent of one another.

I guess it is time to learn VBA. I have coded in my past life, but
not in any type of basic. Can you suggest a good book or online
class to learn VBA? I would sure appreciate it.
Most Access books will have a lot of code in them. The Developers handbook
by Getz and Litwin is a must have in my estimation.

Make sure you understand the event model and that most of the time you will
be writing very few lines of code in any one function.

Northwind has many examples of forms subform combinations.

I would still look at a tabbed form with the subforms on each page but the
code for opening and passing arguments is basically a one liner.
 
Back
Top