Multiple field query form

H

hsdaguilar

Hello,

I have a form called "frmPrimary" which contains fields "txtAddress" and
"cboStreet".
I have a subform (linked to frmPrimary) called "frmProject" which contains
the field "Keyword".
And
I have a subform (linked to subformProjects) called "frmEntitlements" which
contains the fields "Entitlement Type" and "Entitlement Id".

I have created a form called "frmQuery" with all these same fields and an
option group with three options: 1. Address , 2. Keyword and 3. Entitlement

If you select option 1 it enables the fields txtAddress and cboStreet, etc...

My goal is that once you press the OK button depending on which option you
selected and the value input in the corresponding fields, "frmPrimary" would
open to the corresponding record.

In other words, they can find a record in frmPrimary based on an address, a
keyword, or an entitlement.

Note: One Address can have mutliple projects (each project has it's own
Keyword) and each Project can have multiple entitlements.

I was thinking something like
If grpPrimaryQuery = 1 Then
DoCmd.OpenForm "frmPrimary" and then I'm at a loss, especially when it comes
to Keyword and Entitlement Type/Id because they are on the subforms.

I'm sortoff a newbie and would appreciate any assistance. Thank you.
 
A

Amy Blankenship

From the help for OpenForm:

The OpenForm method carries out the OpenForm action in Visual Basic.

expression.OpenForm(FormName, View, FilterName, WhereCondition, DataMode,
WindowMode, OpenArgs)

expression Required. An expression that returns one of the objects in the
Applies To list.

FormName Required Variant. 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 Optional AcFormView.

AcFormView can be one of these AcFormView constants.
acDesign
acFormDS
acFormPivotChart
acFormPivotTable
acNormal default. Opens the form in Form view.
acPreview
If you leave this argument blank, the default constant (acNormal) is
assumed.


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

WhereCondition Optional Variant. A string expression that's a valid SQL
WHERE clause without the word WHERE.

DataMode Optional AcFormOpenDataMode.

AcFormOpenDataMode can be one of these AcFormOpenDataMode 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 Optional AcWindowMode.

AcWindowMode can be one of these AcWindowMode constants.
acDialog
acHidden
acIcon
acWindowNormal default
If you leave this argument blank, the default constant
(acWindowNormal) is assumed.


OpenArgs Optional Variant. 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.

Remarks
For more information on how the action and its arguments work, see the
action topic.

The maximum length of the wherecondition argument is 32,768 characters
(unlike the Where Condition action argument in the Macro window, whose
maximum length is 256 characters).

You can leave an optional argument blank in the middle of the syntax, but
you must include the argument's comma. If you leave a trailing argument
blank, don't use a comma following the last argument you specify.

Example
The following example opens the Employees form in Form view and displays
only records with King in the LastName field. The displayed records can be
edited, and new records can be added.

DoCmd.OpenForm "Employees", , ,"LastName = 'King'"HTH;Amy"hsdaguilar"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

open main form using linked form criteria 0
Subform Question 0
Select Case 0
combo box control source 1
Repost-multiple id numbers 2
dsum query 1
Show calculation from main form in sub form 2
copy text/value 7

Top