"wherecondition" seems to be ignored

B

Bob Howard

Hi all (A2K win98se);

I have a main form with three button opening the same secondary form ---
each requires a different subset of the same data.

For "simplicity" I defined one query (with no criteria, hence no Where
clause was generated in the query itself) to be used as the RecordSource of
the secondary form. And I put a "wherecondition" in each of the three
openforms in the main form.

The problem is that the "wherecondition" is being ignored.

Here's an example of one of them:

DoCmd.OpenForm "Donation Process Form", , , "[Deposit Year Table].[Is Year
Open?] = 'Yes' AND [Deposit Batch Table].[Batch Type] = 'D'"

When this failed, I tried an applyfilter in the OnOpen event of the
seconrdary form (applying one of the three filters depending on which data
subset would be used --- I determined this from a parameter passed to the
secondary form). Here's an example of the applyfilter I coded in the OnOpen
event:

DoCmd.ApplyFilter , "Donation Process Form", , , "[Deposit Year Table].[Is
Year Open?] = 'Yes' AND [Deposit Batch Table].[Batch Type] = 'D'"

Please note in the above that I coded the comma so this would be treated as
a wherecondition.

This also accomplished nothing.

So I broke down and created three identical queries, set the criteria in
each, and now I set the RecordSource in the OnOpen event to point to the
correct query. I don't like that because it's a waste of resources and
makes subsequent maintenance difficult since if anything changes, I need to
reflect the identical change in three queries.

Any clues as to what I'm doing wrong??

Bob (@Martureo.Org)
 
K

Ken Snell [MVP]

Guessing that your [Is Year Open?] field is a "yes/no" field? If so, try
this:

DoCmd.OpenForm "Donation Process Form", , , "[Deposit Year Table].[Is Year
Open?] = True AND [Deposit Batch Table].[Batch Type] = 'D'"
 
B

Bob Howard

Well, actually it's a required 3-character text field containing either
"Yes" or "No" (the validation rule specifies accordingly)...

I guess I'm sort of a simple soul....

Bob.

Ken Snell said:
Guessing that your [Is Year Open?] field is a "yes/no" field? If so, try
this:

DoCmd.OpenForm "Donation Process Form", , , "[Deposit Year Table].[Is Year
Open?] = True AND [Deposit Batch Table].[Batch Type] = 'D'"

--

Ken Snell
<MS ACCESS MVP>


Bob Howard said:
Hi all (A2K win98se);

I have a main form with three button opening the same secondary form ---
each requires a different subset of the same data.

For "simplicity" I defined one query (with no criteria, hence no Where
clause was generated in the query itself) to be used as the RecordSource
of
the secondary form. And I put a "wherecondition" in each of the three
openforms in the main form.

The problem is that the "wherecondition" is being ignored.

Here's an example of one of them:

DoCmd.OpenForm "Donation Process Form", , , "[Deposit Year Table].[Is Year
Open?] = 'Yes' AND [Deposit Batch Table].[Batch Type] = 'D'"

When this failed, I tried an applyfilter in the OnOpen event of the
seconrdary form (applying one of the three filters depending on which data
subset would be used --- I determined this from a parameter passed to the
secondary form). Here's an example of the applyfilter I coded in the
OnOpen
event:

DoCmd.ApplyFilter , "Donation Process Form", , , "[Deposit Year Table].[Is
Year Open?] = 'Yes' AND [Deposit Batch Table].[Batch Type] = 'D'"

Please note in the above that I coded the comma so this would be treated
as
a wherecondition.

This also accomplished nothing.

So I broke down and created three identical queries, set the criteria in
each, and now I set the RecordSource in the OnOpen event to point to the
correct query. I don't like that because it's a waste of resources and
makes subsequent maintenance difficult since if anything changes, I need
to
reflect the identical change in three queries.

Any clues as to what I'm doing wrong??

Bob (@Martureo.Org)
 
B

Bob Howard

Thanks anyway, but I just discovered this is a bug in SR-1 documented (along
with the workaround) in MSKB article 269380. Bob.
 
K

Ken Snell [MVP]

Post the SQL of the successful queries and let's see what might be the
difference between them and your "WHERE CONDITION" for the forms.

--

Ken Snell
<MS ACCESS MVP>

Bob Howard said:
Well, actually it's a required 3-character text field containing either
"Yes" or "No" (the validation rule specifies accordingly)...

I guess I'm sort of a simple soul....

Bob.

Ken Snell said:
Guessing that your [Is Year Open?] field is a "yes/no" field? If so, try
this:

DoCmd.OpenForm "Donation Process Form", , , "[Deposit Year Table].[Is
Year
Open?] = True AND [Deposit Batch Table].[Batch Type] = 'D'"

--

Ken Snell
<MS ACCESS MVP>


Bob Howard said:
Hi all (A2K win98se);

I have a main form with three button opening the same secondary
form ---
each requires a different subset of the same data.

For "simplicity" I defined one query (with no criteria, hence no Where
clause was generated in the query itself) to be used as the
RecordSource
of
the secondary form. And I put a "wherecondition" in each of the three
openforms in the main form.

The problem is that the "wherecondition" is being ignored.

Here's an example of one of them:

DoCmd.OpenForm "Donation Process Form", , , "[Deposit Year Table].[Is Year
Open?] = 'Yes' AND [Deposit Batch Table].[Batch Type] = 'D'"

When this failed, I tried an applyfilter in the OnOpen event of the
seconrdary form (applying one of the three filters depending on which data
subset would be used --- I determined this from a parameter passed to the
secondary form). Here's an example of the applyfilter I coded in the
OnOpen
event:

DoCmd.ApplyFilter , "Donation Process Form", , , "[Deposit Year Table].[Is
Year Open?] = 'Yes' AND [Deposit Batch Table].[Batch Type] = 'D'"

Please note in the above that I coded the comma so this would be
treated
as
a wherecondition.

This also accomplished nothing.

So I broke down and created three identical queries, set the criteria
in
each, and now I set the RecordSource in the OnOpen event to point to
the
correct query. I don't like that because it's a waste of resources and
makes subsequent maintenance difficult since if anything changes, I
need
to
reflect the identical change in three queries.

Any clues as to what I'm doing wrong??

Bob (@Martureo.Org)
 
K

Ken Snell [MVP]

Bob Howard said:
Thanks anyway, but I just discovered this is a bug in SR-1 documented
(along
with the workaround) in MSKB article 269380. Bob.

Yes, this applies to using macros for Apply Filter. (It also is an issue in
VBA for those versions of ACCESS too).

But it doesn't address your original issue... that the OpenForm action was
'ignoring' your "WhereCondition" expression.
 
B

Bob Howard

Thanks Ken!

I noticed that the article didn't apply to the openform, but since it did
apply to the applyfilter (too many apply's in this sentence) I "assumed"
that it was the same root problem. My assumption was based on my belief
that in the openform usage, Access was probably doing an applyfilter on my
behalf behind the scenes. I'll have the opportunity to test this with other
copies of Access shortly, so that will give me a better idea as to whether
my assumption holds water.

Meanwhile, I'm not in a position right now to persue this since I have a
workaround operating. I'm scheduled to deliver the next release of my
application in two days --- so I'll have to put this matter on the back
burner until after I close that out and burn the distribution CDs. Then
I'll have a bit more time to investigate this further.

I can test this using A2K Runtime on my test machine, and using Access 2003
(is this A23K, or A2K3 ?) at a client site. The application will not
function with anything older than A2K (that was the minimum design spec
level).

Thanks for your continued help. I'll keep eveyone posted in about a week
with what I find out.

Bob (@Martureo.Org)


----- Original Message -----
From: Ken Snell [MVP]
Newsgroups: microsoft.public.access.forms
Sent: Sunday, May 22, 2005 12:00 PM
Subject: Re: "wherecondition" seems to be ignored



Bob Howard said:
Thanks anyway, but I just discovered this is a bug in SR-1 documented
(along
with the workaround) in MSKB article 269380. Bob.

Yes, this applies to using macros for Apply Filter. (It also is an issue in
VBA for those versions of ACCESS too).

But it doesn't address your original issue... that the OpenForm action was
'ignoring' your "WhereCondition" expression.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top