How to use openArgs with Set

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all, is it possible to pass an Arg with using set? I use

Docmd open myform,,,,openarg

to pass args to the form, but can this be done with

Set frm = New form_myform 'args where?????

TIA.
 
Harry

The two commands aren't doing the same thing.

The syntax of the OpenForm command includes openargs so you can pass a value
into a form as it opens.

The "Set" command associates, so what "args" are you trying to associate
(the syntax doesn't allow this, as I recall)?
 
Jeff, thank you for your response. I am trying to pass/associate some value
to the form when the new instance of the myform is open. Is this possible or
a work around solution? Thanks.
 
Harry

One approach might be to have the new instance of the form "look" at
whatever already holds the value you are trying to pass (?perhaps another
form?). You could have that form refer to the value in a control on another
form with something like:

Forms!SomeOtherForm!SomeControlName
 
Just build some custom properites for the form, and make them public.

Public Property LET SSN(strS as string)

' this sets up the forms SSN number

m_ssn = strS

end Properyty

Public Propery GET SSN as string
' this propery retuns the SSN number
SSN = m_ssn
end Proprty

Public Function RunStuff

' cool code to do whatever proicessing you want

end function.

Now,

Set frm = New form_myform

frm.SSN = "1233"

msgbox "the fomrs SSN value we passed is " & frm.SSN

frm.SSN = "2343"
frm.Whatever Else You wna to pass to form
frm. Even smore
Now, get the form to run some code based on the values passed

frm.RunStuff

Notice how even intei-sense works! So, you are building objects here!!

So, don't think of passing values back and forth, but think of a form as a
object, and you set/return values, and any public function defined in the
forms code is a method of that form. While ms-access is not a object
orientated programming environment, forms are in fact object, and the old
fashioned idea of passing values has given way to setting values of the
object..and then telling the object what to do.
 
Back
Top