Hi all,
Sorry, I have not been able to find out how to do this, yet it should be
very simple. I am opening another form (formB) and trying to pass multiple
text box values from formA to formB. I am using the following:
DoCmd.OpenForm "CS_Email_Form", , , , , , [Contact_Email].Value
which works great. However, if I try to pass multiple fields (ie, Order_ID
and Contact_Email) it begins requesting that I put quotes around the fields
(I am not able to get out of the VBA editor)- but once I doput the quotes
around my OpenArgs, it then just passes the text inside the quotes, and not
the values from FormA. I have tried creating variables, but the same thing
happens. Is there a special way to make the quotes so that I may pass
multiple values to formB? Any help is always appreciated, thanks!
-gary
Stefan Hoffmann - 24 Jul 2007 13:02 GMT
hi Gary,
> Is there a special way to make the quotes so that I may pass
> multiple values to formB? Any help is always appreciated, thanks!
OpenArgs := Value & Delimiter & Value & Delimter & Value
use Split() to seperate the values:
Dim OpenArgStings() As String
OpenArgStings() = Split(OpenArgs, Delimiter)
As the delimiter may not be part of the payload you need to escape it, e.g.
Value = Replace(OrigValue, _
Delimiter, _
Delimiter & Delimiter)
and
OrigValue = Replace(OpenArgsStrings(x), _
Delimiter & Delimiter, _
Delimiter)
mfG
--> stefan <--
Andy Hull - 24 Jul 2007 13:58 GMT
Hi Gary
You can only pass one "thing" via openargs although that "thing" could be
several values concatenated into a single string with suitable separators.
So you could pass one string and then use vba in the opening form to split it
into its parts again.
However, if your calling form is, say, MyForm then the opening form can use
the values directly using the following syntax...
[Forms]![MyForm].[Order_ID] and [Forms]![MyForm].[Contact_Email]
As long as the calling form stays open.
hth
Andy Hull
> Hi all,
> Sorry, I have not been able to find out how to do this, yet it should be
[quoted text clipped - 9 lines]
> multiple values to formB? Any help is always appreciated, thanks!
> -gary
Gary Dolliver - 24 Jul 2007 15:36 GMT
Hi Andy,
Thanks for the reply, that makes sense. I may be able to use the "open
form" method, however, I will be calling this one form (formB) from 2
different forms. Is it possible to have an "if" statement that
if formA is open
[Forms]![FormA].[Order_ID] and [Forms]![FormA].[Contact_Email]
elseif formC is open
[Forms]![FormC].[Order_ID] and [Forms]![FormC].[Contact_Email]
end if
???? thank you so much for the reply!
-gary
> Hi Gary
>
[quoted text clipped - 27 lines]
> > multiple values to formB? Any help is always appreciated, thanks!
> > -gary
Klatuu - 24 Jul 2007 15:42 GMT
The answer is yes.
One way would be to pass the name of the Calling form to the form you are
opening. If you want to test to see if a form is open, the syntax is
If CurrentProject.Allforms("FormA").Isloaded Then

Signature
Dave Hargis, Microsoft Access MVP
> Hi Andy,
> Thanks for the reply, that makes sense. I may be able to use the "open
[quoted text clipped - 39 lines]
> > > multiple values to formB? Any help is always appreciated, thanks!
> > > -gary
Gary Dolliver - 24 Jul 2007 16:16 GMT
Wow, thank you - that works! One more, what if both forms are open? (as one
form is an order entry form and the other an inquiry form, and there may be
instances of both being open and on different records) - is there a way to
have the form being opened only relate to the form that called it to be
opened?
thanks again!
-gary
> The answer is yes.
> One way would be to pass the name of the Calling form to the form you are
[quoted text clipped - 45 lines]
> > > > multiple values to formB? Any help is always appreciated, thanks!
> > > > -gary
Klatuu - 24 Jul 2007 14:18 GMT
As Andy said, only one text value can be passed in the OpenArgs and reading
values directly from the other form, provided it is open, is an option. If
you want to pass all the value in one string and parse it out, the best way
is to use the Split function. It creates an array of strings in a Variant
variable using a delimiter. For example, if you have strThing = "A/B/C" and
call the Split Funtion:
varStuff = Split(strThing, "/")
varStuff will now contain 3 elements
varStuff(0) will = "A"
varStuff(1) will = "B"
varStuff(2) will = "C"

Signature
Dave Hargis, Microsoft Access MVP
> Hi all,
> Sorry, I have not been able to find out how to do this, yet it should be
[quoted text clipped - 9 lines]
> multiple values to formB? Any help is always appreciated, thanks!
> -gary
Gary Dolliver - 24 Jul 2007 16:08 GMT
Awesome! Thank you! I passed a string value of all the fields I wanted and
then split it on the "onLoad" event for opening the second form, with the
following:
varSplitString = Split([StringPass], "/")
Me.[Recipient].Value = varSplitString(0)
Me.[Order_ID].Value = varSplitString(1)
My fields populated and all is well, thank you so much!
-gary
> As Andy said, only one text value can be passed in the OpenArgs and reading
> values directly from the other form, provided it is open, is an option. If
[quoted text clipped - 22 lines]
> > multiple values to formB? Any help is always appreciated, thanks!
> > -gary