Open Form and Filter Subform

MonkeyChico

Registered User.
Local time
Yesterday, 20:51
Joined
May 11, 2010
Messages
18
I have a command button that I want to open a form and filter a field on a subform. The main form is "frm_QuotingListAll" the subform is "frm_Quoting Datasheet subform" and the field is "Transfer Status". Could someone please help me with the subform control syntax?


Private Sub cmd_viewinprogess_Click()
On Error GoTo Err_cmd_viewinprogess_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_QuotingListAll"
stLinkCriteria = "forms![frm_Quoting Datasheet subform]![Transfer Status] = 'In Progress'"

DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmd_viewinprogess_Click:
Exit Sub
Err_cmd_viewinprogess_Click:
MsgBox Err.Description
Resume Exit_cmd_viewinprogess_Click

End Sub
 
Subforms are referenced in the style of:

Code:
Forms!mainformname!subformcontrolname.Form!controlname

Technically a control on a main form is referenced as:
Code:
Forms!mainformname.Form!controlname

However the Form property is the default property of a form so it can be dropped just like Value can be dropped from a control because it is the default property.

The Form property must be included in a subform reference because the subform control does not have default property.
 
Thanks Galaxiom. I followed your instructions and the syntax seemed to be correct however, it would not filter by the control. I figured out another way - I made the filter field default to what I wanted to be filtered on open and I made the form open action the filter cmd.
 

Users who are viewing this thread

Back
Top Bottom