Using a physical object in a from thru a module?

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????
 
A

Alex Dybenko

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
 

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