0
votes

I am trying to open a form in MS Access (Office 365). I am using the following VBA code:

DoCmd.OpenForm "CommunityAccountList", acNormal, , , , , "Community = " & Me.CommunityID.Value

The code was working fine, and then it started producing the error:

Run-time error '3070': The Microsoft database engine does not recognize '5239' as a valid field name or expression.

I preceded this line of code with 'MsgBox "Community = " & Me.CommunityID.Value' which produced the following popup: "Community = 1". I cannot figure out where Access is getting the 5239 from. Any help would be appreciated.

1
The filter criteria is shown in wrong argument. I don't see how it could have ever worked. Delete 3 commas. - June7
I just tested and I don't get error but also does not apply filter. So something else is happening. You have this criteria in OpenArgs argument. Is opening form trying to do something with OpenArgs? - June7
Welcome to SO. If you are applying a WHERE clausule when opening the form, it should be something like DoCmd.OpenForm "CommunityAccountList", acNormal, , "Community = " & Me.CommunityID.Value, as suggested by @June7. - Foxfire And Burns And Burns
The Community=Me.CommunityID.Value is an OpenArgs, not a search filter. I am merely passing a variable required to open the form. This worked previously on this line, as well as in other places I used the DoCmd.OpenForm. I still do not understand where Access is getting 5239 from. - RonEdmontonCanada
What do you do with the string passed by OpenArgs? Whatever that is, must be what is causing error. If you want opening form filtered then put that criteria in WHERE CONDITION argument. - June7

1 Answers

0
votes

Resolved: The issue was not with the DoCmd line or the query being run. The issue was on the form being opened. Somehow I copied 5239 into the Order By property field for the form.