Calling a Public Function from a Module... (1 Viewer)

QMDirk

Member
Local time
Today, 16:57
Joined
Nov 16, 2019
Messages
52
So if I have a Public Function named "LCode" in Module1, and Form1 has 2 textboxes: tbox1 and tbox2. When a numeric value is entered in tbox1, I want the function in Module1 to be applied to it, and display the result in tbox2. Can anyone please just tell me how to do that? help files seem to talk all around "how" to use functions but I'm not hearing what I need to fully understand what is being said. Thanks.
 

Minty

AWF VIP
Local time
Today, 23:57
Joined
Jul 26, 2013
Messages
10,355
I think you should be able to put something like

= LCode(tbox1)

In the control source of tbox2?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:57
Joined
Feb 19, 2013
Messages
16,553
depends on your parameters for your function e.g. if it is something like this, then Minty's suggestion should work
Code:
function LCode(ctl as control) as variant
    if isnumeric(ctl) then Lcode=ctl.name 'or whatever code you are using 
end function
 

Micron

AWF VIP
Local time
Today, 19:57
Joined
Oct 20, 2018
Messages
3,476
Ja, but when? You'll likely raise and error (even if it's one like #Name or #Error) if you simply make the control source the result of a function and the input value isn't present. Your 'calculation' might even raise 'division by zero' error - it all depends on your code. I'm thinking you need to figure out if the function call should just be as described, or OnCurrent, or AfterUpdate, or BeforeUpdate; in the last 2 cases, on the form or control event - who knows?
 

Users who are viewing this thread

Top Bottom