Pass parm to form from switchboard

vagelisr

Registered User.
Local time
Tomorrow, 01:19
Joined
Apr 28, 2011
Messages
87
Hi to all

I want to pass 2 parameters in my form.

Is there any way to pass these parameters from switchboard???

my code is

Dim Args As Variant
Args = Split(Me.OpenArgs, "|")
Parm_Open_Form = Args(0)
Parm_Customer_Type = Args(1)

Thanks and regards
 
Yes, you can pass the parms from the switchboard - but only if you already know what the values are for both parms.
'start code ------------------

Private Sub BtnName_Click()

Dim strArgs As String

strArgs = "xx" & "|" & "yy"

DoCmd.OpenForm “[FormName]”,,,,,,strArgs

End Sub
'end code -----------------------
Replace xx, yy and FormName with your own values.
 
but only if you already know what the values are for both parms.
Jeanette - What do you mean, if you already know what the values are for both parameters? You can use variables, etc. and not just hard coded values. But are you talking about query parameters? (not sure if that's what you meant or what so I thought I would try to clarify by posting another example).

vagelisr:

You can use the OpenArgs really in quite different ways and you can pass the values you want (multiple values) by delimiting them.
Code:
Private Sub BtnName_Click()
 
Dim strArgs As String
Dim SomeVariable As String
 
SomeVariable = VBA.Environ("username")
 
strArgs = Me.Name & "|" & SomeVariable
 
DoCmd.OpenForm “[FormName]”, OpenArgs:= strArgs
 
End Sub

And then in the form being opened:
Code:
Private Sub Form_Load()
Dim varSplit As Variant
 
   If Me.OpenArgs <> vbNullString Then
      varSplit = Split(Me.OpenArgs, "|")
       Me.txtFormName = varSplit(0)
       Me.txtUser = varSplit(1)
   End If
 
End Sub

So the concept can be modified to be used in all sorts of ways. It isn't all that clear how you wanted to use it so this is more of a general example.
 
Last edited:
Yes, that is the same thing that I am saying.
If the OP doesn't have any way for the switchboard form to know the values to place in the OpenArgs, it won't work.
 
First of all thanks for your answers.........

Second: I want to pass this parm FROM THE SWITCHBOAD!!!!!

The solution i have found (and for my prodject work correct) is....

1)I have add a new column in the switchboard table Name ArgumentParm type string (is the place where i put my parms with the same way as you said) something like 10|90 etc etc

And in my Switchboard screen i have add the line

Const conCmdOpenFormBrowse_Parm = 33 after the
Const conCmdOpenFormBrowse = 3

and the
Case conCmdOpenFormBrowse_Parm
DoCmd.OpenForm rs![Argument], , , , , , rs![ArgumentParm] after the
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]


so my Private Function HandleButtonClick(intBtn As Integer) is like this

Private Function HandleButtonClick(intBtn As Integer)
' This function is called when a button is clicked.
' intBtn indicates which button was clicked.
' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenFormBrowse_Parm = 33
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Const conCmdOpenPage = 9

.
.
.
.
.
.

Select Case rs![Command]

' Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument]

' Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd
' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]
' Open a form with parms.
Case conCmdOpenFormBrowse_Parm
DoCmd.OpenForm rs![Argument], , , , , , rs![ArgumentParm]

After this all is the same.........

Now if i want just to open a form without parms i use the number 3 in the switchboard
If i wand to pass parm i use the number 33 and in the ArgumentParm column i add my parameters :cool:

I hope to help someone else how has the same problem with me.......;)
 

Users who are viewing this thread

Back
Top Bottom