Pass parameter to opening form from more than one calling form

M

Marcel K.

I need to pass a parameter to a form that opens after a
click event has fired. I can pass using openargs, but on
the open event of the opening form, the trouble I am
having with this approach is that I have a variable that
references the.OpenArgs property of a form....but if I
have another form calling my loading form - the first
reference to the .openargs property doesn't work...since
the form is not running..

I guess the concern here is can I use the .openargs, I
just need to know which form is doing the calling?..then I
can I can retreive the string value passed in on
the .openargs from that calling form?

Your reply is most appreciated.
 
R

Ronald Dodge

DoCmd.OpenForm
<FormName>,<View>,<FilterName>,<WhereCondition>,<DataMode>,<WindowMode>,<Ope
nArgs>

The above code is in the form that's openning up another form.

In this case, it's the <OpenArgs> argument that you put in the string format
of the different paramaters that you require your form's Open Event to use.

Here's an example from Access' help file that would be put in the form
that's being openned from the called form:

Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Dim strEmployeeName as String
strEmployeeName = Me.OpenArgs
Dim RS as DAO.Recordset
Set RS = Me.RecordsetClone
RS.FindFirst "LastName = '" & strEmployeeName & "'"
If Not RS.NoMatch Then
Me.Bookmark = RS.Bookmark
End If
End If
End Sub

Note that the DoCmd.OpenForm first puts the string format paramters into the
OpenArgs Property of the form that's being openned.

The Open Event of the form that's being openned is triggered and can use the
OpenArgs Property on it's own self.
 
A

alan

-----Original Message-----
I need to pass a parameter to a form that opens after a
click event has fired. I can pass using openargs, but on
the open event of the opening form, the trouble I am
having with this approach is that I have a variable that
references the.OpenArgs property of a form....but if I
have another form calling my loading form - the first
reference to the .openargs property doesn't work...since
the form is not running..

I guess the concern here is can I use the .openargs, I
just need to know which form is doing the calling?..then I
can I can retreive the string value passed in on
the .openargs from that calling form?

Your reply is most appreciated.

.See if this helps
If Len(Me.OpenArgs) > 0 Then
Me.Variable = Me.OpenArgs
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top