I would like to send multiple (2 to 3) parameters when opening a form. I
know how to open with a single parament, but not multiple.
Assuming you are using a newer version of Access that includes the
Split() function.
First Copy and Paste the following Function into a Module:
Public Function ParseText(TextIn As String, X) As Variant
On Error Resume Next
Dim var As Variant
var = Split(TextIn, ",", -1)
ParseText = var(X)
End Function
========
To pass an OpenArgs when opening the second form:
DoCmd.OpenForm "FormName", , , , , , "Hello,GoodBy,Mary,Lamb"
or if you are passing field data:
DoCmd.OpenForm "FormName", , , , , ,[FieldA] & "," & [FieldB] & "," &
..... etc.
To read the OpenArgs in the second form,
code the second form's Load event:
If Not IsNull(Me.OpenArgs) Then
Dim intX as integer
Dim intY As Integer
intX = InStr(Me.OpenArgs, ",")
Do While intX <> 0
intY = intY + 1
intX = InStr(intX + 1, Me.OpenArgs, ",")
Loop
For intX = 0 To intY
' Change the below line to use the OpenArgs however you want to.
Debug.Print ParseText(Me.OpenArgs, intX)
Next intX
End If
If your version of Access does not have Split(), you can use InStr(),
Left(), and Mid() functions to split the OpenArgs into it's various
parts.