wherecondition in OpenForm

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

Guest

When using the Whercondition within the Openform,is it possible to access the
built predicate in the called form?

I need to extract a value from the Where clause built in a pop up form,
which then calls the form I am working on. The value in the where clause is
to be used to perform some calculations on unbound columns.

Or do I need to pass a parameter to mirror the WhereCondition statement.

Cheers,
Steve
 
When you OpenForm with with a WhereCondition, Access applies the
WhereCondition to the Filter of the form, so you could read it from there.

Passing it in OpenArgs would also work.
 
Excuse my gross ignorance on this matter, but how do I read the contents of
the filter?

If I were to use OpenArgs instead of the Wherecondition, is this a better
method of calling a form with a given set of parameters?

Thanks for your patience, I am new to all this!!!!
 
Presumably you have code that does something like this:
DoCmd.OpenForm "Form1",,,"ID = 999"

Then in the module of that form, you are trying to discover the ID = 999
bit. If so, you can read it from the form's Filter property like this:
Debug.Print Me.Filter
 
The way to find out what filter has been applied to the form (albeit from a
WhereCondition argument) you can use

Me.Filter

OpenArgs and WhereConditions do slightly different things. OpenArgs relies
on the form itself to interpret the parameter passed. This could be a where
condition, but it could also be a value, a username, some calculated value,
in fact anything. The form then contains the logic about what to do, ie,
restrict the records, permit read/write access, change the way the form
looks .. .anything.

Using a WhereCondition relies on the 'calling' form to restrict the record
that can be shown. . . . and that's it.
 
Back
Top