-----Original Message-----
Helen,
Ok, fair enough. I can't see why you want to open the form if there are
no records. I thought that was the whole idea. If you use the
expression I suggested...
DCount("*","YourQuery")>0
.... for the OpenForm action, it should open the form if there are
record, and not open the form if there are not records. What is the
name of the query that the second form is based on? Is the query called
Opportunities? And this query returns the records based on the ?PartID
of the current record on the first form, right? What is the name of the
second form? The first time you told me it was called Plants Using
PartID, and now it looks like you have changed this to Opportunities,
which is what I thought was the name of the first form. Well, if you
have changed the name of the form, has the macro been changed
accordingly? Or are you actually trying to open a second instance of
the first form? If so, this is a somewhat tricky procedure, and I would
suggest another approach. So when you tried my earlier suggestion, it
"didn't work", does this mean the form still opened when it shouldn't
have, or does it mean the form didn't open, even when it should have, or
does it mean you got an error?
--
Steve Schapel, Microsoft Access MVP
That was the first one that I tried, and since it didn't
work, I thought maybe the "*" meant something else, so I
tried everything I could think of to substitute the "*".
Do I not open the form in the first place? Do I set the
condition as you wrote it with the action being to open
the form? I think I tried that, and it didn't work.
Thanks again,
Helen
-----Original Message-----
Helen,
I notice that of the various options you tried, is not
included the
method I suggested in my previous reply. Any reason
for
this?
--
Steve Schapel, Microsoft Access MVP
Helen wrote:
Hi Steve!
You are a king among men!! However, when I tried your
suggestion, it's still opening the form and not giving
me
my MsgBox. Here's what I did:
Action: Open form where [partID] is on the
opportunities
form (because I think it needs to open the form with
the
query in the first place)
Condition: DCount ("Plant","Opportunities") is null
(and I
tried "<1" and "<=1")
Action: MsgBox "No other plant is using this part
number"
Condition: ...
Action: Close form "Plants using PartID"
Condition: DCount ("Plant","Opportunities") is not null
(and other variations of the same thing)
Action: Open form where partID = forms![Opportunities]!
[PartID]
I even tried to setvalue [Plant using partID].
[invisible]
until it looks at the conditions, but that's not
working,
either!
I've tried substituting DCount ("*") with PartID, with
Plant, and even with the *, but none of those work,
either.
I've been stuck on this problem for about two weeks
now,
and I'm about ready to throw this computer out the
window
(do you think that would help?)
Thanks again, I can't tell you how much I appreciate
your
help!
Helen
-----Original Message-----
Helen,
I think this will work for your Condition...
DCount("*","YourQuery")>0
(... where YourQuery is the name of the query that the
Plants Using
PartID form is based on.)
--
Steve Schapel, Microsoft Access MVP
Helen wrote:
I'm trying to set a condition where a form will open
only
if a partID that I'm entering into a form is available
in
another form.
The form I'm working in is "Opportunities". The
separate
form is "Plants using PartID". Once I enter a partID
into
my opportunities form, I have a macro on AfterUpdate
that
will automatically open the "Plants using PartID" form
and
show me what plants are using the same PartID.
HOWEVER, I
don't want anything to happen if there is no other
plant
using that PartID. How do I set my condition in my
macro
to NOT open the "plants" form if there aren't any
other
plants using that part number?
Anyone? Anyone? Any ideas?
Thanks!!!
.
.
.