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

Filter two text boxes

Status
Not open for further replies.

at51178

Technical User
Mar 25, 2002
587
US
I have two text boxes that I would like to filter based on what is entered on a previous form but for some reason I can't get it to work.

This is what I have so far I am new at this so I probably have it written incorrectly.
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("qry_Quality_Scores", dbOpenDynaset)

With rs
Do Until .EOF
.Edit
.Fields("EvaluatorName") = Forms!frm_Switchboard!Team_Leader
.Fields("EmployeeName") = Forms!frm_Switchboard!Employee
Loop
End With

Set db = Nothing
Set rs = Nothing
 
Add the line next to the >>> to the loop below

With rs
Do Until .EOF
.Edit
.Fields("EvaluatorName") = Forms!frm_Switchboard!Team_Leader
.Fields("EmployeeName") = Forms!frm_Switchboard!Employee
>>> .update
Loop
 
And
[tt].movenext ' after the .update line[/tt]

Those lines should perform update of the two fields. It's often a bit more common that the 'Do'- line looks something like this:

[tt]Do While Not .Eof[/tt]

Also consider adding a line with:

[tt].Close[/tt] ' between the 'Loop' and 'End With' lines

If this isn't solving your challenge, please elaborate a bit more on what happens, what errormsg/error# if available and a bit more on what you want't to achieve.

Roy-Vidar
 
Thanks for the response


Well here's the good news

the application doesn't freeze up when running the original code

the bad news is that when I added the recommended changes to the code and run it
it deletes everythning in the database for the two tex boxes and rewrites the fields with the search criteria. it is not filtering the form at all.


This is updated code that i am using word for word



Private Sub Form_Load()

Me.RecordsetClone.MoveLast
Me.RecordsetClone.MoveFirst
Me.txtRecord_Count = Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("qry_Quality_Scores", dbOpenDynaset)


With rs
Do While Not .EOF
.Edit
.Fields("EvaluatorName") = Forms!frm_Switchboard!txtTeam_Group_Leader
.Fields("EmployeeName") = Forms!frm_Switchboard!txtEmployee
.Update
.MoveNext
Loop
.Close
End With

Set db = Nothing
Set rs = Nothing
End Sub
 
If you are going to open up a recordset using a predefined qry, you must use the following code.

Dim db as DAO.Database
Dim rst as DAO.recordset
Dim prm as DAO.parameter
Dim qdf as DAO.queryDef

Set db = currentdb
Set qdf = db.QueryDefs("qry_Quality_Scores")

For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst = qdf.OpenRecordset(dbOpenDynaset)

Then, you can use the filtered recordset as you with the code that you have
 
Aaaahhh - are you trying open a form filtered on the two fields on a switchboard form?

If so, you should be able to to that thru setting the "linkcriteria" in the openform routine (from the switchboard):

[tt]dim sLink as string
stlink="EvaluatorName = '" & me!Team_Leader & "' AND " & _
"EmployeeName = '" & me!Employee & "'"
docmd.openform "frmYourForm",,,sLink[/tt]

If this doesn't do the trick, I'll repeat from my previous post. Please elaborate more on what you wan't to achieve! As you see, we're all trying to guess your intentions.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top