Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where clause in Docmd.openform

Status
Not open for further replies.

dhaveedh

Programmer
Aug 13, 2003
112
GB
I have two forms A and B. I want to open form B when I click a button in form A. This is straighforward.

What I want to do is specify a criteria in the where clause of the Docmd.openform statement. This criteria is to serve as a filter for Form B so that i only display certain records.

The two forms are based on the same table and I want Form B to open from Form A based on a criteria in the table.

Can anyone help?



KISS - Keep It Simple Sugar!
 
Top of my head...

Add a public member variable to formB

Public m_WhereClause as string


Then, set the variable to the right clause before you show it.


FormB.M_whereClause = &quot; WHERE A < 2&quot;
docmd.openform &quot;FormB&quot;

The form can then look at the variable to get what it needs.

eg:

MyRecSet= currentdb.openrecordset(&quot;Select blah&quot; & m_WhereClause)


 
Whoa! What about using the where criteria parameter that's built into the openform command? Check it out in the help file, or just type
call docmd.openform(

and access will prompt you to fill in the appropriate paramenters. If you try it and can't get it to work, post your code here, and let us know what unexpected results you're getting.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top