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

Referring to a subform control

Status
Not open for further replies.

FredaH302

MIS
Dec 15, 2006
22
US
Hi,

I am desparately trying to find some help with this. It seems as if it should be simple.

I have a main form that displays customers. It has a subform displaying related records. The subform has a combo box which is used to filter the subform records.

The combo box (named Cat_Search) is tied simply to a value list that provides three values:

Common
Security
Other

The subform has a [Category] field that stores one of these values for each of its records.

When a user selects one of the values (above), the subform should filter to display only those matching records. The [Cat_Search] box exists on the subform which it is filtering. The subform is in a tab control.

The only code I have is on [Cat_Search]:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_Available_list"

stLinkCriteria = "[category]=" & "'" & Me![Cat_Search] & "'"
DoCmd.ApplyFilter stDocName, stLinkCriteria

The code works fine if I open the subform by itself, but when it is placed within another form it doesn't. The problem appears to be in the "stlinkcriteria" line. Should it be rewritten?

Can anyone help?

 
The way to refer to a subform is:
Mainform!subformCONTROL_NAME.Form!subformControl

Make sure you use the *Control Name* of the subform, not it's actual name, they may differ.
--Jim
 
Freda,
I will clarify...I used a syntax where I assumed 'Mainform' was a form variable.

If it's not, use this instead:
Forms!Mainform!subformCONTROL_NAME.Form!subformControl
OR
if it's on the 'mainform'
me!subformCONTROL_NAME.Form!subformControl

--Jim
 
How are ya FredaH302 . . .
Code:
[blue]   Me.Filter = "[category]=" & "'" & Me![Cat_Search] & "'"
   Me.FilterOn = True[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top