Hi,
I am confused as where the public variables and functions should reside within Access 2007.
Here’s my problem:
Using an example about this subject matter posted by a TechRepublic guru, I created a form with two unbound fields named MyInteger and ResultInteger respectively. There is also a push button that has a on click event.
I declared a public variable within the form class module:
Public Resultnumber As Integer
Option Compare Database
Private Sub Calc_PB_Click()
‘ this code will be triggered by the clicking the push button on the form
calcRoutine (Me.MyInteger)
‘Invoking the public sub routine stored in another module
Me.ResultInteger = Resultnumber
End Sub
I then coded a public subroutine within the standard module called Global Code:
Public Resultnumber As Integer
Option Compare Database
Public Sub calcRoutine(MyInteger As Integer)
Resultnumber = MyInteger * 2
End Sub
When Calc_PB_Click() was executed from the form, no matter what MyInteger value was entered, the ResultInteger value was always zero – the calcRoutine public subroutine was never called.
So how should one declare and place public variables and functions so that they can be used in other class modules or form events?
Thanks in advance!
JL