473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Reference form objects from a module

Hi

I have a module where I put all my functions and sub procedures. How do I
from the module best reference objects in other forms?

I have a form with a datagrid, and in the module I have a procedure to fill
this datagrid.
The datagrid is called dg, the form frmEventMain

Would this be correct:

frmEventMain.dg.Datasource = dt when I reference the datagrid in another
form?

/A.

Jan 17 '07 #1
3 1451
Lee
Andy:

It's not clear to me if frmEventMain is an instance of a form or the
name of the class wherein the form is defined. Assuming it's an
instance of the form you could...

1) Call your proc passing frmEventMain as a parameter
2) Call your proc passing frmEventMain.dg as a parameter
3) Assuming frmEventMain is visible within your proc, you could access
frmEventMain.dg directly.

My preference would be #2 because it would make your proc more
generally useful.

--
// Lee Silver
// Information Concepts Inc.

Andy.I wrote:
Hi

I have a module where I put all my functions and sub procedures. How do I
from the module best reference objects in other forms?

I have a form with a datagrid, and in the module I have a procedure to fill
this datagrid.
The datagrid is called dg, the form frmEventMain

Would this be correct:

frmEventMain.dg.Datasource = dt when I reference the datagrid in another
form?

/A.
Jan 17 '07 #2
Thanks

I'll give it a try
"Lee" <ls*****@information-concepts.comwrote in message
news:11**********************@v45g2000cwv.googlegr oups.com...
Andy:

It's not clear to me if frmEventMain is an instance of a form or the
name of the class wherein the form is defined. Assuming it's an
instance of the form you could...

1) Call your proc passing frmEventMain as a parameter
2) Call your proc passing frmEventMain.dg as a parameter
3) Assuming frmEventMain is visible within your proc, you could access
frmEventMain.dg directly.

My preference would be #2 because it would make your proc more
generally useful.

--
// Lee Silver
// Information Concepts Inc.

Andy.I wrote:
>Hi

I have a module where I put all my functions and sub procedures. How do I
from the module best reference objects in other forms?

I have a form with a datagrid, and in the module I have a procedure to
fill
this datagrid.
The datagrid is called dg, the form frmEventMain

Would this be correct:

frmEventMain.dg.Datasource = dt when I reference the datagrid in another
form?

/A.
Jan 17 '07 #3
Andy.I wrote:
I have a module where I put all my functions and sub procedures. How do
I from the module best reference objects in other forms?
If a method requires a reference to a Form then pass it one as an
argument to the method.
Better still, if the method primarily affects the Form based on other
data that you supply, move the method into the Form class.
I have a form with a datagrid, and in the module I have a procedure to
fill this datagrid.
I would suggest that's the wrong way round.
I would attach this method to the Form and pass the data, however you
retrieve it, to the method.

HTH,
Phill W.
Jan 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Krackers | last post by:
How do you write a function which returns a reference to an array. I can only get a function to return a copy of the array itself. I've had a look at some other threads in this group an the return...
15
by: Ron Adam | last post by:
Does anyone have suggestions on how to improve this further? Cheers, Ron_Adam def getobjs(object, dlist=, lvl=0, maxlevel=1): """ Retrieve a list of sub objects from an object. """
4
by: Dave Lauberts | last post by:
Hi Sorry to ask a silly question, I am 'self taught' in using access vb and I came trying to use fIsAppRunning to see if excel is running in the background but when I try and compile the code I...
7
by: Weaver | last post by:
I need to create an object (a recordset) that will not go out of scope outside the sub that creates it. I've tried placing the Dim statement in the General area and in another mod as Global;...
4
by: Keith Chadwick | last post by:
I am having some trouble referencing an Application("myVar") variable from within a module.vb file on my ASP.NET site. According to the documentation I should be able to reference...
2
by: Martin Ortiz | last post by:
Ugh.... All classes are copy by reference, even if you use "ByVal" and NOT "ByRef" it's still a copy by reference. Of course, as a consequence, if you change any values of the object you passed...
2
by: Mark D | last post by:
Hi Relative vb.net newbie here... I have a Windows Form application with a few subroutines in a separate module. From one of the subroutines, I want to get the value of a label or text box on...
7
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.