Using a physical object in a from thru a module?

  • Thread starter Thread starter Joao
  • Start date Start date
J

Joao

I am trying to call a function in a module from a form. It will fill some
data in a real ListBox object placed in a from. Using this code:

In Module:
Public FP As Form_Process ' Name of the Form
....
FP.ObjListBox.AddItem rstSQL.Fields(0), VarTemp
....

I got an object required... but if I use:

In Module:
Public FP As Form
....
Set FP = Form_Process
....
FP.ObjListBox.AddItem rstSQL.Fields(0), VarTemp
....

it works, but some code prior written become instable, like variables not
receiving data, etc... anyone????
 
Hi,
you need to pass form variable to your function in module:

in module:

function FillLst (oForm as form)
....
oform.ObjListBox.AddItem rstSQL.Fields(0), VarTemp

end function

in form:

FillLst me

OR you can also call it from any place like:

FillLst Forms("MyForm")


--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
Back
Top