docmd.OpenForm -- a question about the parameters

Hi,

I'm using the docmd.OpenForm command to open a form when a button is clicked. I'm also trying to pass the form to be opened some information about what data to show when the button is clicked; however, I'm very confused about the following possible paramters I could use. So, for 500 points could someone succinctly summarize the difference between:
FilterName, WhereCondition, OpenArgs

and describe a typical situation when you'd use it?

Are there any corresponding properties that the form to be opened needs to have set for any of these?

[For context, the first form is contains multiple user search parameters, and the second is an unbound Main form (with buttons) with the subform displaying the resultset desired by the user.]
epugliseAsked:
Who is Participating?
 
hnasrConnect With a Mentor Commented:
FilterName:
Create a query with the required fields to filter. Add the criteria and save it.
This will act as the filterName in the command.
Can be reused in other situations.

WhereCondition:
a simple way for experts, if used with limited nuber of fields.

OpenArgs:
A string that can be carried to the opened form.  You can use it in the load event, for example, like any variable.
0
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
if you want to open the form to show filtered records
* use the WhereCondition
if you want to pass information when opening a form
* use the OpenArgs

i never use FilterName
0
 
epugliseAuthor Commented:
Ok that's easy. Thanks. One follow up question if I may. What kinds of information would you pass in OpenArgs... form properties or something?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
epugliseAuthor Commented:
I would be interested in hearing from someone who does use the FilterName...
0
 
Rey Obrero (Capricorn1)Commented:
i never use FilterName, it is erratic...
0
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
<What kinds of information would you pass in OpenArgs...> anything relevant to the form that you are opening.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
Ditto on the FilterName argument - I don't use it. It used to work in 2003 and below if you inadvertantly entered a WHERE clause for the Filter argument, but that broke for good in 2007, and now if you don't enter the name of a well-formed Filter query you'll either get an error of the form won't filter.

Note also that one form can reference data/values on another, and in some cases that makes more sense than trying to use OpenArgs. For me, OpenArgs is best suited for something like on-the-fly filtering. If you need to move a LOT of data to another form, then it's often best to have FormB refer to FormA:

Me.txtTitle = Forms("FormA").txtTitle

Or use Properties of a form, and set those properties from the "calling" form.
0
 
epugliseAuthor Commented:
Thank you all for the input! This was a helpful tutorial!!
0
 
hnasrCommented:
Welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.