filtering a form based on a filter on an open form

D

DawnTreader

hello all

i am trying to get a form to open filtered based on the records
showing in another form. not necessarily 1 specific record but based
on the filter of the first form.

i did this trick with a report, but then the report is based on the
same query as the form. now i need to know how i could filter a form
based on the open form that i push the button to open the second form
on.

any and all help appreciated.
 
J

John W. Vinson

hello all

i am trying to get a form to open filtered based on the records
showing in another form. not necessarily 1 specific record but based
on the filter of the first form.

i did this trick with a report, but then the report is based on the
same query as the form. now i need to know how i could filter a form
based on the open form that i push the button to open the second form
on.

any and all help appreciated.

You would need to set either the second form's Recordsource, or its Filter, or
the WhereCondition argument in the OpenForm method to match the criteria in
the form's Filter. Since they are different queries (and presumably may have
different tables and different fields) this may will be rather tricky!

What are the Recordsources of the two forms? How is the first form's filter
being set? What would you want to happen if the Filter includes fields not
represented on the second form (or can that even happen)?
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
D

DawnTreader

You would need to set either the second form's Recordsource, or its Filter, or
the WhereCondition argument in the OpenForm  method to match the criteria in
the form's Filter. Since they are different queries (and presumably may have
different tables and different fields) this may will be rather tricky!

What are the Recordsources of the two forms? How is the first form's filter
being set? What would you want to happen if the Filter includes fields not
represented on the second form (or can that even happen)?
--

             John W. Vinson [MVP]
 Microsoft's replacements for these newsgroups:
 http://social.msdn.microsoft.com/Forums/en-US/accessdev/
 http://social.answers.microsoft.com/Forums/en-US/addbuz/
 and see alsohttp://www.utteraccess.com

actually i got it. i had the wrong subform name and was hanging on
that. additionally i needed to use the recordsourceclone and it worked
wonders.

CurrentDb.Execute "DELETE * FROM utblHQTrackerFilter"

' MsgBox "cleared, ready to go"

Set rsinsertIssues =
Me.Form.sfrmqryIssueTracker.Form.RecordsetClone

' If IsNull(Me.Form.sfrmqryIssueTracker.Form.Filter) = False Then
With rsinsertIssues
rsinsertIssues.MoveFirst
Do While Not .EOF
' MsgBox rsinsertIssues("IssueID")
CurrentDb.Execute "INSERT INTO utblHQTrackerFilter
( IssueID ) VALUES (" & rsinsertIssues("IssueID") & ");"
.MoveNext
Loop
End With
' End If

DoCmd.OpenForm stDocName

i was trying to not do this if there was no filtering on the form but
i cant seem to work that out. the only problem this causes is that the
code does the insert even though i want to see all the records on the
second form anyways. it causes a bit of a delay, but i can live with
that.
 

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

Top