Filter Problem

B

Bill Phillips

I am converting from Access 2003 to Access 2007. I have a form that has a
filter applied on After-Update as follows:

Private Sub FindItem_AfterUpdate()
FindLoc.DefaultValue = ""
DoCmd.ApplyFilter , "InvItem = Forms!Inventory!FindItem"
Me.OrderBy = "InvTag"
Forms!Inventory!cboProductSearch = Forms!Inventory!FindItem
End Sub

After I update the data I get no rows returned. I have checked my data and
made certain there wre records available for my test item. However, If I
display the menu item that is labelled "Refresh All" I get the desired
result. How do I accomplish the same task in VB?

Thanks,

Bill
 
J

Jeanette Cunningham

Hi Bill,

I usually avoid using Docmd.ApplyFilter, simple because many mvp's use the
Filter and FilterOn methods.

Private Sub FindItem_AfterUpdate()
Dim strFilter As String
FindLoc.DefaultValue = ""
Me.Filter = "InvItem = " & Forms!Inventory!FindItem
Debug.Print Me.Filter
Me.FilterOn = True
Me.OrderBy = "InvTag"
End Sub

Use the Debug.Print line to see what access gets for the value for the
filter
The above assumes that InvItem is a number data type, use
"InvItem = """& Forms!Inventory!FindItem & """" for text data type.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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