Solved

docmd.OpenForm -- a question about the parameters

Posted on 2011-02-24
9
439 Views
Last Modified: 2012-05-11
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.]
0
Comment
Question by:epuglise
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 167 total points
ID: 34974895
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
 

Author Comment

by:epuglise
ID: 34974915
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
 

Author Comment

by:epuglise
ID: 34974921
I would be interested in hearing from someone who does use the FilterName...
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 30

Accepted Solution

by:
hnasr earned 167 total points
ID: 34975180
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34975307
i never use FilterName, it is erratic...
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 167 total points
ID: 34975317
<What kinds of information would you pass in OpenArgs...> anything relevant to the form that you are opening.
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 166 total points
ID: 34976375
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
 

Author Comment

by:epuglise
ID: 34982570
Thank you all for the input! This was a helpful tutorial!!
0
 
LVL 30

Expert Comment

by:hnasr
ID: 34983638
Welcome!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question