Open a form and pass a number to it (1 Viewer)

AlbertoG

New member
Local time
Today, 06:57
Joined
Oct 3, 2019
Messages
3
Hello. I want to open an existing form from VBA and pass a number to it, so that it is used by some of its controls: combo boxes, lists and associated VBA routines.

--------------
Current code:
Dim strW As String


strW = "[Stk_ID] = " & CStr(Me.Chosen_Stk_ID)

DoCmd.OpenForm "Stk_QAs_Form", acNormal, , strW
--------------
Results:
At the debugger window, strW is "[Stk_ID] = 6"
But when the form Stk_QAs_Form opens, it asks for the value of Stk_ID.
Even if I write a number at the input box, it is reflected in the control Stk_ID.

Any ideas?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:57
Joined
Oct 29, 2018
Messages
21,358
Hi.You're using the WhereCondition argument to pass a filter to the form you're opening. Perhaps you meant to use the OpenArgs argument to pass the value of Stk_ID instead. Just a thought...
 

AlbertoG

New member
Local time
Today, 06:57
Joined
Oct 3, 2019
Messages
3
Thank you, theDBguy. I will try it.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:57
Joined
May 7, 2009
Messages
19,175
is the recordsource of the form you are trying to open is
based on a query. check the query for the parameter.
 

Users who are viewing this thread

Top Bottom