Why isn't Requery working?

R

Renee

Hello all,

Here is the code on a command button on the parent form:
Dim strFilter As String
Dim strAgent As String

'Build criteria string for agent field
If IsNull(Me.Agent) Then
strAgent = "Like '*'"
Else
strAgent = "= '" & Me.Agent.Value & "'"
End If

'Combine criteria string into a WHERE clause
strFilter = "Name " & strAgent
'Apply the WHERE clause
CurrentDb.QueryDefs("qry_Sales").SQL = "SELECT " & _
"tbl_Sales.RecordID, " & _
"tbl_Sales.Name, " & _
"tbl_Sales.Product, " & _
"tbl_Sales.Quantity, " & _
"tbl_Sales.Date, " & _
"tbl_Sales.Price " & _
"FROM tbl_Sales " & _
"WHERE " & strFilter & ";"
'Requery the subForm
Me!Sales.Requery

When I select different sales agents and click apply, nothing happens. If I
select an agent, then go into design view and click right back to form view,
the sub form (pivot chart) is updated.

Any suggestions would be greatly appreciated!
 
O

Ofer

How about, instead of requery try this

Me.Sales.form.Recordsource = "Select * From qry_Sales"
 

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