Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem working with Module

Status
Not open for further replies.

GerardMcL

Technical User
Aug 5, 2004
212
IE
Hi,

I am tying to access a datagrid from the module but I am having problems.

I have tried just
dgTools.DataSource = dt

but no go. I have tried Form1.dgTools & Form1.Controls(dgTools)

Im too stuck in my VB6 ways. Any help as always is greatly appreciated.
 
When I reference a DataGrid in a module, I use a sub or function with a parameter that is a DataGrid. For example:

Public Sub SetUpAuthDataGridStyle(ByRef dg As DataGrid)

End Sub

Note the parameter: ByRef dg As DataGrid

This provides a reference to the desired DataGrid through 'dg'.

If you don't want to - or can't - pass the DataGrid to a procedure, you will need a reference to the form on which it lies. In the module, you would ned something like this:

Public DataGridForm as Form1

Then when you need to reference the grid in the module, you would need to set the DataGridForm variable to the calling form (Form1):

Module1.DataGridForm = Me

You then should be able to reference the grid like this:

DataGridForm.dgTools


Let meknow if this helps, or if you need any clarification, etc.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top