Using Variable in Where Clause

G

GeorgieGirl

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.
 
M

Mike Painter

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.
 
G

GeorgieGirl

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.
 
Top