HOW DO YOU: Access the data control from bas.module 
Author Message
 HOW DO YOU: Access the data control from bas.module

I have the data control on frmMain. I am trying to set up the
databasename, recordsource and querydef properties from a module to
keep code more portable, but keep getting "object variable not
declared" on the data1.databasename=name. I have tried explicitly
identifying the data control by using formname.data1.databasename and
I still get the same error. I have tried loading the form to be sure
that the controls are visible to the rest of the project, but that
doesnt seem to effect anything. The code works fine if I leave it as
CBF (code behind form) but i want the binding of the data control in a
module, not a form.

any ideas would be greatly appreciated...

thanks in advance...




Fri, 19 Mar 1999 03:00:00 GMT  
 HOW DO YOU: Access the data control from bas.module

Why don't u try passing the control ByRef to the function, so that the =
function could manipulate the properties.

e.g

Public Function SetDataControl(ByRef tmp as Control)
        tmp.databasename =3D .....
        tmp.recordsource =3D ....
        tmp.querydef=3D....
End Function

Hope it helps! Good day...
Anthony Ng



Quote:
> I have the data control on frmMain. I am trying to set up the
> databasename, recordsource and querydef properties from a module to
> keep code more portable, but keep getting "object variable not
> declared" on the data1.databasename=3Dname. I have tried explicitly
> identifying the data control by using formname.data1.databasename and
> I still get the same error. I have tried loading the form to be sure
> that the controls are visible to the rest of the project, but that
> doesnt seem to effect anything. The code works fine if I leave it as
> CBF (code behind form) but i want the binding of the data control in a
> module, not a form.
>=20
> any ideas would be greatly appreciated...
>=20
>=20
> thanks in advance...
>=20
>=20

>=20



Fri, 19 Mar 1999 03:00:00 GMT  
 HOW DO YOU: Access the data control from bas.module

Quote:

>I have the data control on frmMain. I am trying to set up the
>databasename, recordsource and querydef properties from a module to
>keep code more portable, but keep getting "object variable not
>declared" on the data1.databasename=name. I have tried explicitly
>identifying the data control by using formname.data1.databasename and
>I still get the same error. I have tried loading the form to be sure
>that the controls are visible to the rest of the project, but that
>doesnt seem to effect anything. The code works fine if I leave it as
>CBF (code behind form) but i want the binding of the data control in a
>module, not a form.

If you want to reference a control (any control) on a form from within
a module, VB needs to know which form the control is on.  Thus you
should be doing

   frmMain!data1.databasename = whatever

Bob Rossney



Sat, 20 Mar 1999 03:00:00 GMT  
 HOW DO YOU: Access the data control from bas.module

I will try that and let you know

thanks Anthony

Quote:

>Why don't u try passing the control ByRef to the function, so that the =
>function could manipulate the properties.
>e.g
>Public Function SetDataControl(ByRef tmp as Control)
>    tmp.databasename =3D .....
>    tmp.recordsource =3D ....
>    tmp.querydef=3D....
>End Function
>Hope it helps! Good day...
>Anthony Ng



Sun, 21 Mar 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Accessing Form Controls From a .BAS module

2. vb4: bas modules and form modules

3. Please help: Updating form controls from a separate BAS module

4. Please help: Updating form controls from a separate BAS module

5. Updating form controls using outside BAS modules

6. bas module doesn't see controls

7. ActiveX control, bas/class module mystery

8. bas module doesn't see controls

9. bas module doesn't see controls

10. Call Access Module from Data Access Page

11. mouse control (MUISTEST.BAS) - muistest.bas (1/1)

12. mouse control (MUISTEST.BAS) - muistest.bas (0/1)

 

 
Powered by phpBB® Forum Software