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

How can I open a form to a specific record?

Status
Not open for further replies.

BabyPowder2u

Programmer
May 4, 2005
87
0
0
US
I have a main form, on this form is a cboSubPOC field which selects a POC name from the available list. I want to right click on that field and open the form POC_ModDel, which gets it's data from tblPOC tabl, and open to the record in referenced in subPOC.

I have the mouseup event to capture the right click.
I don't understand how to open the POC_ModDel form to a specific record.

Any help will be appreciated.

T
 
from access help
DoCmd.OpenForm formname[, view][, filtername][, wherecondition][, datamode][, windowmode][, openargs]

The OpenForm action has the following arguments.

Action argument Description
Form Name The name of the form to open. The Form Name box in the Action Arguments section of the Macro window shows all forms in the current database. This is a required argument.If you run a macro containing the OpenForm action in a library database, Microsoft Access looks for the form with this name first in the library database, then in the current database.
View The view in which the form will open. Click Form, Design, Print Preview, or Datasheet in the View box. The default is Form.
Note The View argument setting overrides the settings of the form's DefaultView and ViewsAllowed properties. For example, if a form's ViewsAllowed property is set to Datasheet, you can still use the OpenForm action to open the form in Form view.
Filter Name A filter that restricts or sorts the form's records. You can enter the name of either an existing query or a filter that was saved as a query. However, the query must include all the fields in the form you are opening or have its OutputAllFields property set to Yes.
Where Condition A valid SQL WHERE clause (without the word WHERE) or expression that Microsoft Access uses to select records from the form's underlying table or query. If you select a filter with the Filter Name argument, Microsoft Access applies this WHERE clause to the results of the filter.To open a form and restrict its records to those specified by the value of a control on another form, use the following expression:[fieldname] = Forms![formname]![controlname on other form]The fieldname argument is the name of a field in the underlying table or query of the form you want to open. The controlname on other form argument is the name of the control on the other form that contains the value you want records in the first form to match.
Note The maximum length of the Where Condition argument is 256 characters. If you need to enter a more complex SQL WHERE clause longer than this, use the OpenForm method of the DoCmd object in Visual Basic instead. You can enter SQL WHERE clause statements of up to 32,768 characters in Visual Basic.
Data Mode The data entry mode for the form. This applies only to forms opened in Form view or Datasheet view. Click Add (the user can add new records but can't edit existing records), Edit (the user can edit existing records and add new records), or Read Only (the user can only view records). The default is Edit.
Notes· The Data Mode argument setting overrides the settings of the form's AllowEdits, AllowDeletions, AllowAdditions, and DataEntry properties. For example, if a form's AllowEdits property is set to No, you can still use the OpenForm action to open the form in Edit mode.· If you leave this argument blank, Microsoft Access opens the form in the data entry mode set by the form's AllowEdits, AllowDeletions, AllowAdditions, and DataEntry properties.
Window Mode The window mode in which the form opens. Click Normal so the form is in the mode set by its properties, Hidden (the form is hidden), Icon (the form opens minimized as a small title bar at the bottom of the screen), or Dialog (the form's Modal and PopUp properties are set to Yes). The default is Normal.
Remarks

This action is similar to clicking the Open button or Design button in the Database window after selecting a form on the Forms tab.
A form can be modal (it must be closed or hidden before the user can perform any other action) or modeless (the user can move to other windows while the form is open). It can also be a pop-up form (a form used to collect or display information that remains on top of all other Microsoft Access windows). You set the Modal and PopUp properties when you design the form. If you use Normal for the Window Mode argument, the form opens in the mode specified by these property settings. If you use Dialog for the Window Mode argument, these properties are both set to Yes. A form opened as hidden or as an icon returns to the mode specified by its property settings when you show or restore it.

When you open a form with the Window Mode argument set to Dialog, Microsoft Access suspends the macro until the form is closed or hidden. You can hide a form by setting its Visible property to No by using the SetValue action.

Tip You can select a form in the Database window and drag it to a macro action row. This automatically creates an OpenForm action that opens the form in Form view.

Switching to Design view while the form is open removes most of the argument settings for the form, such as the Data Mode and Window Mode argument settings. They aren't in effect even if the user returns to Form view or Datasheet view.
The filter and WHERE condition you apply become the setting of the form's Filter property.
 
Have a look at OpenArgs, RecordsetClone, FindFirst, NoMatch and Bookmark.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I am not sure what your key field from the combo box is called but you can put this in the event

DoCmd.OpenForm "POC_ModDel", acViewNormal,,"POC=" & me.cboSubPOC


Hope this helps.

OnTheFly
 
Thanks Everyone,

I had researched the filter properties on forms before & didn't understand using them, same with open args.

Thanks OnTheFly, that is what I needed, I will try it out shortly, I'm leaving for now. Will get back.

T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top