Calling public function from a control

  • Thread starter George Papadopoulos
  • Start date
G

George Papadopoulos

Hello Access users

I have a standard module named 'Queries_module'. Inside I have defined a
function as shown :

Public Function Get_From_Date()
Get_From_Date = Forms!Episkeyh_bash_kwdikou_klinikhs.Get_From_Date()
End Function

As seen the function calls another function which belongs to a form. The
definition of that function in the module
'Forms!Episkeyh_bash_kwdikou_klinikhs' is :

Public Function Get_From_Date()
Get_From_Date = dtFrom_Date ' dtFrom_Date is simply a date variable
End Function

I now have a report. There exists a text box on that report. I am trying to
set the control source of the text box to :
Modules!Queries_module.Get_From_Date().

But it fails! A dialog box pops up asking for the value of
Modules!Queries_module.Get_From_Date().

Is my approach sound? What am I not doing right?

thx, in advance


George Papadopoulos
 
D

Dirk Goldgar

George Papadopoulos said:
Hello Access users

I have a standard module named 'Queries_module'. Inside I have
defined a function as shown :

Public Function Get_From_Date()
Get_From_Date = Forms!Episkeyh_bash_kwdikou_klinikhs.Get_From_Date()
End Function

As seen the function calls another function which belongs to a form.
The definition of that function in the module
'Forms!Episkeyh_bash_kwdikou_klinikhs' is :

Public Function Get_From_Date()
Get_From_Date = dtFrom_Date ' dtFrom_Date is simply a date
variable End Function

I now have a report. There exists a text box on that report. I am
trying to set the control source of the text box to :
Modules!Queries_module.Get_From_Date().

But it fails! A dialog box pops up asking for the value of
Modules!Queries_module.Get_From_Date().

Is my approach sound? What am I not doing right?

thx, in advance

George Papadopoulos

Try just setting the controlsource to

=Get_From_Date()

You shouldn't need to qualify it with the module name at all, and a
"Modules!"-style reference would be a reference to a module that is open
in the VB Editor, which may or may not be the case with Queries_module,
and isn't necessary in order to call a function in the module.
 
D

dandgard

I take it there is some reason why you made the function public in
module vs the forms class. You don't need to call the code in th
class, you can directly access the date control in your form from th
module as long as your form is open.

try your code this way

Get_From_Date = Forms!Episkeyh_bash_kwdikou_klinikhs!dtFrom_Dat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top