Tuesday 15 February 2011

Open Access Form with Filter VBA -


I'm having trouble opening a form using the filter The code that I am trying to run is: < / P>

  DoCmd.OpenForm "MyForm", "[ID] =" & amp; Me.MyListBox.Column (0), acFormEdit, acDialog  

When I run this line, it opens the form, but does not apply the filter.

The FilterOnLoad property is set to true, and I have verified that this is true in the Open Load event.

While in the Form_Load event, Me.FilterOn = False and Me.Filter = "".

What happened to the filter? What am I doing wrong? I tried to set the true.FilterOn property through VBA and then saved the form, but when I open the form again, it gets reset to false.

If I set VBA and then. Filleron property is correct, filter the form correctly I have verified that "Me.MyListBox.Column (0)"

is to say about the FilterName parameter in the DoCmd.OpenForm method help topic:

A string expression that is a valid name query in the current database.

But you are not giving it a query name. I think that you really want the parameter WhereCondition instead:

  DoCmd.OpenForm FormName: = "MyForm" , _ Where compilation: = "[id] =" & amp; Me.MyListBox.Column (0), _DataMode: = acFormEdit, _ WindowMode: = acDialog  

No comments:

Post a Comment