Change public function value

A

Angel

Hi!
I have a public Function stored in a module "MyDates" that stores the fiscal
year, which is used in several forms and reports.

Public Function FisYear() As String
FisYear = DLookup("[FiscalPeriod]", "Dbo_AMC_Info", "[ID] = 1")
End Function

I want to be able to modify the value from a form's "FiscalYear" dropdown
box but do not know how to change the value of a public function from a
private sub on change
The dropdown box pulls all available fiscal years from a table.

SELECT DISTINCT SH_PSUM.BUS_YEAR
FROM SH_PSUM;

Can I pass the selected value to the public function?
Here is what I need:

Private Sub FiscalYear_Change()
???????
End Function

Thanks in adavance!
 
M

Marshall Barton

Angel said:
Hi!
I have a public Function stored in a module "MyDates" that stores the fiscal
year, which is used in several forms and reports.

Public Function FisYear() As String
FisYear = DLookup("[FiscalPeriod]", "Dbo_AMC_Info", "[ID] = 1")
End Function

I want to be able to modify the value from a form's "FiscalYear" dropdown
box but do not know how to change the value of a public function from a
private sub on change
The dropdown box pulls all available fiscal years from a table.

SELECT DISTINCT SH_PSUM.BUS_YEAR
FROM SH_PSUM;

Can I pass the selected value to the public function?
Here is what I need:

Private Sub FiscalYear_Change()
???????
End Function


Functions should be controlled through one or more
arguments. I'm not sure what you want, but maybe something
like:

Public Function FisYear(YearID As Integer) As String
FisYear = DLookup("[FiscalPeriod]", "Dbo_AMC_Info", _
"[ID] = " & YearID)
End Function

Then you will get the same result as before by using:
strYear = FisYear(1)

or if the combo box value is an integer for the desired
year:
strYear = FisYear(Me.FiscalYear)
 

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