OpenArgs questions

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

Evening all,
Is it possible to assign more than one 'thing' to the
OpenArgs property? If so,
a) What's the syntax
b) How do you refer to a particular item?

TIA guys,

Lee
 
Do you mean, can I put multiple "things" into an OpenArgs string so that I
have access to multiple "things" in the form or report that looks at the
string?

If yes, then yes you can put multiple "things" in a text string....simply
concatenate the "things" and separate them by a delimiter of some type (for
example, the pipe character | ); then parse them back into separate "things"
in the opened form or report.
 
Evening all,
Is it possible to assign more than one 'thing' to the
OpenArgs property? If so,
a) What's the syntax
b) How do you refer to a particular item?

TIA guys,

Lee
You can assign many additional OpenArgs.
DoCmd.OpenForm "FormName", , , , , , "New York" & "," & [ControlName]

If the value of [ControlName] is "Chicago" you have passed, as an
OpenArgs, the string "New York,Chicago"

Then in the form being opened, you would use it's Load event to
separate the string before and after the comma.

In the Form's Code window Declaration's section
Option Explicit
Dim strOne as String
Dim strTwo as String

Then in the Load event:
If Not IsNull(Me.OpenArgs) Then
strOne = Left(OpenArgs,InStr(OpenArgs,",")-1
strTwo = Mid(OpenArgs,InStr(OpenArgs,",")+1

strOne (New York) and strTwo (Chicago) can now be used any where in
the form.
 
Lee said:
Is it possible to assign more than one 'thing' to the
OpenArgs property? If so,
a) What's the syntax
b) How do you refer to a particular item?


OpenArgs is just a string and you can put any characters you
want into it.

For example, to pass an invoice number and a PO number to
another form:

DoCmd.OpenForm "formname", OpenArgs:=InvNum & "~" & PNnum

Then parse the two values in the new form's Load event:

lngPos = InStr(Me.OpenArgs, "~")
If lngPos > 0 Then
strInvoice = Left((Me.OpenArgs, lngPos -1)
strPo = Mid(Me.OpenArgs, lngPos +1)
Else
'can't find delimiter
End If
 
Thanks for the comprehensive reply Fred, that's a great
help.

Much appreciated.

Lee
-----Original Message-----
Evening all,
Is it possible to assign more than one 'thing' to the
OpenArgs property? If so,
a) What's the syntax
b) How do you refer to a particular item?

TIA guys,

Lee
You can assign many additional OpenArgs.
DoCmd.OpenForm "FormName", , , , , , "New York" & "," & [ControlName]

If the value of [ControlName] is "Chicago" you have passed, as an
OpenArgs, the string "New York,Chicago"

Then in the form being opened, you would use it's Load event to
separate the string before and after the comma.

In the Form's Code window Declaration's section
Option Explicit
Dim strOne as String
Dim strTwo as String

Then in the Load event:
If Not IsNull(Me.OpenArgs) Then
strOne = Left(OpenArgs,InStr(OpenArgs,",")-1
strTwo = Mid(OpenArgs,InStr(OpenArgs,",")+1

strOne (New York) and strTwo (Chicago) can now be used any where in
the form.


--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
Thanks for the reply Ken. I've also seen FredG's reply
which is helpful too.

You're too kind!

Lee
 
----- Lee wrote: ----

Evening all
Is it possible to assign more than one 'thing' to the
OpenArgs property? If so,
a) What's the synta
b) How do you refer to a particular item

TIA guys

Le

Hi Lee, just re-iterating the other posts - but adding a suggestion to use the split function as an efficient method to separate out the elements of the OpenArgs string

Luc
Jonatha
 
----- Lee wrote: -----
Is it possible to assign more than one 'thing' to the
OpenArgs property? If so,
a) What's the syntax
b) How do you refer to a particular item?

TIA guys,

Lee
Jonathan said:
Hi Lee, just re-iterating the other posts - but adding a
suggestion to use the split function as an efficient
method to separate out the elements of the
OpenArgs string.


As long as Lee's using A2K+, that's an excellent
idea, Jonathan
 
Back
Top