> Unfortuanately you cannot add parameters to the Form_Load event, however you
> can create a Public Sub that you can pass parameters to and open the form
> from there;
> Dim frmObj As Form
> Set frmObj = New frmProject
> frmObj.FrmOpen "PENDING"
> in the form:
> Public Sub FrmOpen(strComplete As String)
> dim pstrSQL as string
> pstrSQL = "SELECT * FROM tblProject WHERE fldComplete = '" & _
> strComplete & "'"
> 'Any other code you want to run before form is shown
> Me.Show
> End Sub
> Bob
> > This method works fine. But, I think there must be a more elegant and
> > proper way to do this, through
> > Hi Collective Knowledge
> > I am developing an application that has one form, that I instantiate
> > new Forms from.
> > Currently, I use the Tag property to pass a value to the formObj to use
> > in a SQL statement. This lets me use the same form for different
> > recordset views.
> > like:
> > Dim frmObj As Form
> > Set frmObj = New frmProject
> > frmObj.Tag = "PENDING"
> > frmObj.Show
> > in the form:
> > Sub Form_Load()
> > dim pstrSQL as string
> > pstrSQL = "SELECT * FROM tblProject WHERE fldComplete = '" & me.Tag &
> > "'"
> > This method works fine. But, I think there must be a more elegant and
> > proper way to do this, through passing arguments to the form instance.
> > Can I declare arguments in the Form_Load module ? ex. Sub
> > Form_Load(gstrComplete as String)
> > How would I do this ?
> > Thanks...
> > Joe
Thank You Bob.... This works great. Now I can pass multiple paramenters to my Form
Instance, without having to parse the Tag property. A much better way to
do this.
One question. I'm calling this Public Sub from a MDI form. When I
invoke frmObj.[list] (FrmOpen is not an Autolist member option). It is
available from the form. Can I make this Public Sub in the Form
accessible to the MDI form (not really necessary, but invokes a
question).
Thanks . . .. You hit the nail right on the head.
joe...