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!

reference variable on form

Status
Not open for further replies.

tomvdduin

Programmer
Sep 29, 2002
155
NL
Sorry, my english isn't good enough to say my problem in a few words. This is what I want to do:

I want to make a generic 'class' all my forms are based on, so I can dynamically make a recordset for the form and lots of other things like creating dynamically searchstrings. Therefore I want to declare a couple of variables in a form, and have a central module build a select string based on these variables. this is what I think of now:
Dim fv_meRst As New ADODB.Recordset 'recordset of the form
Dim fv_mainTable As String 'maintable the form is based on
Dim fv_subTables(99) As String 'subtable, will be joined on the maintable
Dim fv_aantSubtables As Integer 'number of subtables
Dim fv_subTablePrimaryKey(99) As String 'primary key of the subtable
Dim fv_foreignKey(99) As String 'foreign key on the maintable
Dim fv_alias(99) As String 'alias of the subtable, in case of having a subtable declared twice
Dim fv_subTableOuterjoin(99) As Boolean 'do a outer join on a subtable or an inner join?

on the form_open, I want to call a function on a main module that builds the select query based on these arguments given. Only problem is: how can that module reach these variables? These variables are declared in the header of a form-module, not in a sub.

I hope the above is clear enough to answer my question!

Thanks!

Tom
 
Tom,
Either declare your variables as Public so they are visible to all code in your project or (probably the better solution) define a set of custom properties using Public Let/Get statements to hold, set, and return these values.

Hope this helps.
 
Pass the arguments as parameters on the function.

This stops the reliance on the form and makes your code more reusable.
 
OK, I want to go to the 'public variable' option, that seems the easiest and best way for me. Now the following problems occurs:

I have 5 matrices (see first post) witch contains subtable names, foreign key names etc. These matrices only can't be public declared...

I could make a get function, that gives all the needed info back, but I want as much logic as possible in the central module. So if there is a woraround or other way, that's preferable by me.

Does someone have some advice for me?

Greetz,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top