frm as form problem (1 Viewer)

John Sh

Member
Local time
Today, 22:19
Joined
Feb 8, 2021
Messages
408
Hi All. I need to pass a form object from one function to another. The first function has the variable defined as (frm as form).
How do I pass this variable to a second function called by the first. The second function obviously cannot define it as { frm as form).
Also how can i read the value of "frm" whilst stepping through the functions. If I hover over "frm" there is no response.
As always, your replies are appreciated.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:19
Joined
Jul 9, 2003
Messages
16,244
The first function has the variable defined as (frm as form

When you say "variable" do you mean as a parameter between the brackets after the function name?

You can pass forms objects, anything really, from one function to another, within these parameters.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:19
Joined
Jul 9, 2003
Messages
16,244
There's an example of passing a form as a parameter within a function on my website here:-


Look in the class module code for the function:- "fGetAssociateCtrl"
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:19
Joined
Feb 28, 2001
Messages
26,996
You are confusing formal and actual parameters.

The variable names appearing in parentheses during the function declaration are the FORMAL parameters. Those names ONLY apply inside the scope of the function's declaration and they vanish with the End Sub or End Functin that ends this routine. It does not matter what names are used in the function call, because those names are the ACTUAL parameters and are NOT in the scope of the function.

So yes, you can re-use names.
 

Isaac

Lifelong Learner
Local time
Today, 04:19
Joined
Mar 14, 2017
Messages
8,738
If I hover over "frm" there is no response.
Because how can a control tip text represent anything that can't be represented with the text of the control tip text?
If you set frm as a Form object and then had a line of code that referenced it's .Name property, then the control tip text that appears when hovering might be useful
 

John Sh

Member
Local time
Today, 22:19
Joined
Feb 8, 2021
Messages
408
Thank you all for your replies. I do, however, owe you all an apology.
My lifetime as an electronics technician taught me that multiple fault indications generally come from a single source.
In coding, just the opposite is the case. An apparently single problem has many possible causes.
My error was to attribute a bunch of strange happenings to a single source while, in fact, there were many obscure little errors in inherited images and excel data files. These conspired to indicate a problem with the "frm as form" declaration, thanks to my background.
I readily admit to being very much a novice in VBA coding so my sincere apologies to all.
John Sh.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:19
Joined
Oct 29, 2018
Messages
21,357
Thank you all for your replies. I do, however, owe you all an apology.
My lifetime as an electronics technician taught me that multiple fault indications generally come from a single source.
In coding, just the opposite is the case. An apparently single problem has many possible causes.
My error was to attribute a bunch of strange happenings to a single source while, in fact, there were many obscure little errors in inherited images and excel data files. These conspired to indicate a problem with the "frm as form" declaration, thanks to my background.
I readily admit to being very much a novice in VBA coding so my sincere apologies to all.
John Sh.
Sounds like you got it all sorted out. Good luck with your project.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:19
Joined
Feb 28, 2001
Messages
26,996
Sometimes even a person like me, with 50+ years of total programming experience, will incorrectly chase down errors just because it is so easy to do. You DO know the true meaning of "experience" don't you? It is the ability to recognize your mistakes when you make them again.
 

John Sh

Member
Local time
Today, 22:19
Joined
Feb 8, 2021
Messages
408
Unfortunately 80 + years of "experience" is a hard thing to buck!
 

Users who are viewing this thread

Top Bottom