Passing Parameters from one Form to another Form 
Author Message
 Passing Parameters from one Form to another Form

Hi!

I have two forms that can call another form. The called form uses values
from the calling form to limit records.

I have workarounds that I can use but would really like to no if this is
possible or not.

Can I pass parameters between forms?

TIA

Troy



Fri, 02 Sep 2005 10:12:48 GMT  
 Passing Parameters from one Form to another Form
Troy,

Although the code at http://www.pacificdb.com.au/MVP/Code/MyDialog.htm shows
how to create a custom dialog, it also demonstrates how to do just what you
want.

You can also pass values to a form when it start up, using the OpenArgs
parameter.
    DoCmd.OpenForm "frmFormName", , , , , , strSomeValue

In the form's Load or Open events, you can use the OpenArgs parameter, like
so:
    If Me.OpenArgs = "123" Then    'OpenArgs is a string!!!
        'Do whatever...
    End If

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia


Quote:
> Hi!

> I have two forms that can call another form. The called form uses values
> from the calling form to limit records.

> I have workarounds that I can use but would really like to no if this is
> possible or not.

> Can I pass parameters between forms?

> TIA

> Troy



Fri, 02 Sep 2005 10:44:49 GMT  
 Passing Parameters from one Form to another Form

Quote:
> Hi!

> I have two forms that can call another form. The called form uses
values
> from the calling form to limit records.

> I have workarounds that I can use but would really like to no if
this is
> possible or not.

> Can I pass parameters between forms?

Sure.  How to do it, though, depends on what you mean by "calling" a
form.  If you mean each of the two original forms may open the "called
form", you can modify the code that opens the "called form" so as to
pass parameters by way of the OpenArgs parameter of the DoCmd.OpenForm
call.  Along these lines:

    DoCmd.OpenForm "frmCalled", _
                OpenArgs:="My Parameter String"

Then in the Open event of "frmCalled" you would have code that checks
the values of the form's OpenArgs property:

    Private Sub Form_Open(Cancel As Integer)

        Dim strArgs As String

        strArgs = Me.OpenArgs & vbNullString

        If Len(strArgs) > 0 Then
            ' do something with parameter string
            ' in strArgs.
        End

    End Sub

On the other hand, if the purpose of the parameter is to specify some
criteria for the records to be displayed in frmCalled, then you don't
need to pass it in OpenArgs.  Instead, you can specify it via the
WhereCondition argument in the OpenForm call:

    DoCmd.OpenForm "frmCalled", _
            WhereCondition:="SomeField=SomeValue"

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



Fri, 02 Sep 2005 10:55:18 GMT  
 Passing Parameters from one Form to another Form
When you call DoCmd.OpenForm there is a parameter called "OpenArgs"
Then when the form is opened you can called Me.OpenArgs to see what that
value was.

E.g:
DoCmd.OpenForm "frmForm", , , , , , "ParameterX"

Then call this in the Load event of frmForm:
Me.OpenArgs
The value will be "ParameterX"

HTH
--
Luke Bellamy
Newcastle, Australia
http://www.CashWhiz.com.au/Development


Quote:
> Hi!

> I have two forms that can call another form. The called form uses values
> from the calling form to limit records.

> I have workarounds that I can use but would really like to no if this is
> possible or not.

> Can I pass parameters between forms?

> TIA

> Troy



Fri, 02 Sep 2005 10:46:32 GMT  
 Passing Parameters from one Form to another Form
Luke

Thank you for the information. It has come in handy.

Troy


Quote:
> When you call DoCmd.OpenForm there is a parameter called "OpenArgs"
> Then when the form is opened you can called Me.OpenArgs to see what that
> value was.

> E.g:
> DoCmd.OpenForm "frmForm", , , , , , "ParameterX"

> Then call this in the Load event of frmForm:
> Me.OpenArgs
> The value will be "ParameterX"

> HTH
> --
> Luke Bellamy
> Newcastle, Australia
> http://www.CashWhiz.com.au/Development



> > Hi!

> > I have two forms that can call another form. The called form uses values
> > from the calling form to limit records.

> > I have workarounds that I can use but would really like to no if this is
> > possible or not.

> > Can I pass parameters between forms?

> > TIA

> > Troy



Sun, 04 Sep 2005 12:22:45 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Pass parameter to opening form from more than one calling form

2. Passing parameters from one form to another

3. Passing parameters from one form to another

4. Passing Parameter from one form to the other

5. Excel VBA & Forms -- passing parameters to form

6. Updating control in forms/Passing parameters to forms

7. Passing input parameters from form to form to stored procedure

8. pass data one form to another form

9. Passing an argument from one form to a second form Help

10. Passing a value from one form to a specific field on another form


 
Powered by phpBB® Forum Software © phpBB Group