Search code examples
ms-accessvbaopenform

Open form using macro with where clause and it opens dialog box


I have an issue with "where condition" in macro on OpenForm in Access 2016.

I'm struggling with exactly the same issue, meaning a dialog window opening in between forms as in the link below:

Access- Open form with where clause

I have a condition like this in macro builder on OpenForm:

="ID_code_SC = " & [Forms]![SearchFRM_Materiel]![ID_code_SC]

and it still asks me to type the name of the ID. If I type it, it goes to a correct record.

Importantly, my ID is a text, such as ABC_01. So I modified it according to: http://www.baldyweb.com/wherecondition.htm

and I have:

="ID_code_SC = '" & [Forms]![SearchFRM_Materiel]![ID_code_SC] & "'"

but this, on the other hand, opens an empty form and doesn't refer to any record.

I use Access 2016. I'm very new to Access and macros/VBA, so most likely I don't see some basic mistake.


Solution

  • Try this:

    "ID_code_SC = '" & [Forms]![SearchFRM_Materiel]![ID_code_SC] & "'"