docmd.openform where condition does not update

randognb

New member
Local time
Today, 10:52
Joined
Feb 4, 2015
Messages
9
Hi, I am running an .adp accessing data on SQL Server 2008.

I'm trying to take a value from a field and use it to show only records that match that value in a continuous form. I programmed a button to run:

Dim whereString As String

whereString = "[Employee First]='" & Me.txtTest.Value & "'"

DoCmd.OpenForm "test_form", , , WhereCondition:=whereString

when i run the code it worked for the first test value but now I can't get the form to update with any new values I enter in the field.

Examining the continuous form in design mode, I noticed in the property sheet that the ServerFilter property takes the contents of the WhereCondition string but it does not update to reflect the new WhereCondition strings when I change the value in the field and re-run the code.

Am I missing something here?

To be verbose, an example is:
txtTest field is currently "Jeff"
whereString contains "[Employee First]='Jeff'"
initial run of docmd.openform code sets ServerFilter property to "[Employee First]='Jeff'"
close continuous form
change txtTest field to "Donald"
whereString contains "[Employee First]='Donald'"
running docmd.openform code again opens continuous form but ServerFilter property is still "[Employee First]='Jeff'"

I appreciate your time!
 
..
Examining the continuous form in design mode, I noticed in the property sheet that the ServerFilter property takes the contents of the WhereCondition string but it does not update to reflect the new WhereCondition strings when I change the value in the field and re-run the code.
What happen if you delete what you've in the ServerFilter property, (I think it should be empty)?
 
thanks for responding!

If i manually delete the contents and re-run the code then it updates again.

I found out that while i was debugging this problem i'd click "Save" when in design mode which was saving the ServerFilter property. So the key is to not save the form after it's opened so that the ServerFilter property is never saved with the string value.

Kinda strange... you'd think that it should update every time you call docmd.openform with a new WhereCondition...
 

Users who are viewing this thread

Back
Top Bottom