Solved Open form using where argument (1 Viewer)

Eureka99

New member
Local time
Today, 10:17
Joined
Jun 29, 2020
Messages
26
Hi All,

Someone has nicely managed to kill all the VBA in an old database so I have the nice job of putting it all back in.

I need to use a where statement on a DoCmd.Openform, but I cant seem to get it right.

I know some of the field names are not great but at this stage it'd take more time to change them!

Code:
DoCmd.OpenForm "Frm_Shikomi_Register", , , "Blanket Agreement Number=" & Me.ID1

So this is using a Query in a sub form to open a record that matches a criteria (in this case part number). It the sub form returns a list and i need to open the form where the Blanket Agreement Number (on the form I'm trying to open) matches the ID1 from the query.

IN both cases its Text. The Blanket agreement is comprised of 3letters and 4 numbers.

What am I doing wrong?
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:17
Joined
Sep 21, 2011
Messages
14,238
You need single quotes (or triple double quotes) if the value concatenated is text?
You syntax will only work for numerics. As you have spaces in the field name best to enclose that with [ and ]
 

cheekybuddha

AWF VIP
Local time
Today, 10:17
Joined
Jul 21, 2014
Messages
2,272
What am I doing wrong?
Not accounting for the spaces in your field names.

Also, you must pass your text argument as a string

Try:
Code:
DoCmd.OpenForm "Frm_Shikomi_Register", , , "[Blanket Agreement Number]='" & Me.ID1 & "'"

PS. Welcome to AWF!
 

Users who are viewing this thread

Top Bottom