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

Need Help with Form Filtering 1

Status
Not open for further replies.

ArtPM

Technical User
Jun 24, 2002
13
0
0
US
I am having problems filtering a form: The following code, using Access2000, works on the first execution, but not after that, unless I initialize (close then open) the form or execute the ShowAllRecords command twice. The qury itself seems to work correctly but the previously filtered results get displayed again.

Private Sub cboAssignedTo_AfterUpdate()
Dim DB As Database, Q As QueryDef
Dim criteria As String, strSQL As String
Dim ctl As Control
Dim itm As Variant
Dim strDocName As String
strDocName = "_Jacksonville Action Register"
Set DB = CurrentDb()
Set Q = DB.QueryDefs("filterAssignedTo")
Q.SQL = " SELECT AR_Jcvl.*, * FROM AR_Jcvl WHERE (((AR_Jcvl.AssignedTo) Like [Forms]![_Jacksonville Action Register]![cboAssignedTo]))ORDER BY AR_Jcvl.AssignedTo;"
DoCmd.OpenForm strDocName, acViewNormal, "filterAssignedTo"
Exit Sub
End Sub

This code works using Access2002 running in Access2000 file format.

The only difference I see is that one is using MS Object Model 10.0 vesus 9.0. ANY SUGGESTIONS?????
 
How about trying:
Code:
Private Sub cboAssignedTo_AfterUpdate()
  Me.Filter = "AssignedTo Like """ & cboAssignedTo & """"
  Me.FilterOn = True
End Sub
This assumes that AR_Jcvl is the record source for the form. If it isn't, you just want to make sure that the field reference in front of the word "Like" is in the form's record source. You might also have to add a Me.Requery to force the form to refresh with the new filtered recordset.

Kevin
:)
 
Kevin,

Thank you for your help!

Your solution is simple, but EFFECTIVE! Works great!

Thank you again.

Art
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top