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

PopupForm Apply filter to MainForm

Status
Not open for further replies.
May 5, 2000
168
US
I have unbound combo boxes on an unbound subform embedded in my main form that provide selections for filters on my (single)main form. When a selection is made from one or more of the combo boxes the click event on a "go" button triggers a pop-up (continuous)form that returns all the matches. On the pop up form the user "clicks" the record that is desired. On that "click" event I want the main form underneath to find the selected record. Would the code look something like this?

It isn't working


Private Sub Form_Click()

Dim stLinkCriteria As String

DoCmd.ApplyFilter , Me![ContactID] = Forms![frmRolEdit]![ContactID]

End Sub
[sig][/sig]
 
You need to activate the filter a different way.
Change your code in the sub form to this.

Private Sub Form_Click()

Forms("YourMainForm").SetFilter Me.ContactID

End Sub

Put this in your main form module

Public Sub SetFilter(varContactID as Variant)

DoCmd.ApplyFilter , Me![ContactID] = varContactID

End Sub

Let me know if it works for you.
[sig]<p>John A. Gilman<br><a href=mailto:gms@uslink.net>gms@uslink.net</a><br>[/sig]
 
It didn't work. It seems like this should be an easier task. [sig][/sig]
 
sorry about the mistake. I should have tested it first!

Put this in the click event on your subform.

Dim strFilter As String
strFilter = &quot;ContactID = &quot; & Me.ContactID
Forms(&quot;YourMainFormName&quot;).Filter = strFilter
Forms(&quot;YourMainFormName&quot;).FilterOn = True

You need to be using a Number field type for this to work, if your ContactID is a charactor field let me know. [sig]<p>John A. Gilman<br><a href=mailto:gms@uslink.net>gms@uslink.net</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top