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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a Subform based on Condition 1

Status
Not open for further replies.

marcoman44

IS-IT--Management
Dec 22, 2003
62
US
The first form is "RX" which has "Provider_ID" as a field. The second form is "Provider" which provides basic information on the Provider. The RXform is in DataSheet view and I want to be able to double click on these fields to provide a filter to the "Provider Form": First Name, Last Name, Provider _ID.

I am trying this, I think I need to better understand the Where Condition and how to call the routine:

Private Sub viewProvider()

DoCmd.OpenForm "Provider"

Exit Sub


How do I achieve this?




Thanks,

Fred
 
The complete syntax for the openform method is

DoCmd.OpenForm formname[, view][, filtername][, wherecondition][, datamode][, windowmode][, openargs]

The definition of each argument is defined in Microsfot helps file aas follow:

formname
A string expression that's the valid name of a form in the current database.
If you execute Visual Basic code containing the OpenForm method in a library database, Microsoft Access looks for the form with this name first in the library database, then in the current database.

view
One of the following intrinsic constants:
acDesign
acFormDS
acNormal (default)
acPreview
acNormal opens the form in Form view.
If you leave this argument blank, the default constant (acNormal) is assumed.

filtername
A string expression that's the valid name of a query in the current database.

wherecondition
A string expression that's a valid SQL WHERE clause without the word WHERE.

datamode
One of the following intrinsic constants:
acFormAdd
acFormEdit
acFormPropertySettings (default)
acFormReadOnly
If you leave this argument blank (the default constant, acFormPropertySettings, is assumed), Microsoft Access opens the form in the data mode set by the form's AllowEdits, AllowDeletions, AllowAdditions, and DataEntry properties.

windowmode
One of the following intrinsic constants:
acDialog
acHidden
acIcon
acWindowNormal (default)
If you leave this argument blank, the default constant
(acWindowNormal) is assumed.

openargs
A string expression. This expression is used to set the form's OpenArgs property. This setting can then be used by code in a form module, such as the Open event procedure. The OpenArgs property can also be referred to in macros and expressions.
For example, suppose that the form you open is a continuous-form list of clients. If you want the focus to move to a specific client record when the form opens, you can specify the client name with the openargs argument, and then use the FindRecord method to move the focus to the record for the client with the specified name.
This argument is available only in Visual Basic.

An simple example to add the where condition can be written as:

DoCmd.OpenForm "Provider", , ,"Provider_ID = '" & Forms![RX]![Provider_ID] & "'"

Option # 2, You can use the create command button wizard, choose Form operations-Open form and choose the 'select the open the form and find specific data to display' and see what codes is put behind the button.

Good luck!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top