can arguments be passed between form_load events?

can arguments be passed between form_load events?

Post by Hank » Sun, 06 Jun 1999 04:00:00



I tried to add an argument to one of my form's "Form_Load" event so that an
entirely different form could pass that argument...Needless to say, VB had a
hissy fit and it didn't work.  Has anyone had any luck doing this.  I could
always just declare a global variable and then there would be no need to
pass the variable as an argument to the other form, but I try to avoid
global vars like the plague.  BTW, here's what I tried to do:

============================================
Private Sub Form_Load (Qry as QueryDef)
Set rst = Qry.OPenRecordset
End Sub

 
 
 

can arguments be passed between form_load events?

Post by John Keysto » Sun, 06 Jun 1999 04:00:00


Hank:

I'm not surprised that you got a hissy fit from VB after what you tried to get
it to do.  However, if the idea is to pass a parameter to a form when you load
and show it from another form, you might be able to use the following approach:

In Form2 put:

Option Explicit

Private m_s As String

Public Function PassParameter(ByVal s As String)
    m_s = s
    Me.Show
End Function

If you then call this function from Form1 (or any other form):

Form2.PassParameter("abc")

the parameter will be passed and Form2 will be loaded and shown.

John.....


> I tried to add an argument to one of my form's "Form_Load" event so that an
> entirely different form could pass that argument...Needless to say, VB had a
> hissy fit and it didn't work.  Has anyone had any luck doing this.  I could
> always just declare a global variable and then there would be no need to
> pass the variable as an argument to the other form, but I try to avoid
> global vars like the plague.  BTW, here's what I tried to do:

> ============================================
> Private Sub Form_Load (Qry as QueryDef)
> Set rst = Qry.OPenRecordset
> End Sub


 
 
 

can arguments be passed between form_load events?

Post by Jeff Ashle » Sun, 06 Jun 1999 04:00:00


I vote for making the querydef a public property of the second form, which set
and then load the form.

> I tried to add an argument to one of my form's "Form_Load" event so that an
> entirely different form could pass that argument...Needless to say, VB had a
> hissy fit and it didn't work.  Has anyone had any luck doing this.  I could
> always just declare a global variable and then there would be no need to
> pass the variable as an argument to the other form, but I try to avoid
> global vars like the plague.  BTW, here's what I tried to do:

> ============================================
> Private Sub Form_Load (Qry as QueryDef)
> Set rst = Qry.OPenRecordset
> End Sub

 
 
 

can arguments be passed between form_load events?

Post by David Freita » Mon, 07 Jun 1999 04:00:00



Quote:

> I tried to add an argument to one of my form's "Form_Load

You can add a form global variable or property and set the property of the
form before invoking it and the form can then access this property.

David

 
 
 

can arguments be passed between form_load events?

Post by clou » Mon, 07 Jun 1999 04:00:00


I vote for the property method David mentioned.