B
BruceM
I use some controls and code, such as custom navigation buttons and
associated code, over and over. I have seen the recommendation to use a
standard module for such things, but am not sure I am implementing it
properly. To use a simple example, the code to go to the next record
(command button Click event) is:
DoCmd.GoToRecord , , acNext
That line of code is in a public function named TheNextRecord in the code
module. In the command button's Click event line I put:
=TheNextRecord()
That works, but I don't know if it is the best way to do this. There is
error handling in the functions.
Where this doesn't work is in my code for custom navigation buttons. In the
form's Current event I have (in part):
Dim strCurrent As String
strCurrent = Me.CurrentRecord
This is the beginning of code to put the current and total records into a
text box (e.g. Record 1 of 3). However, I cannot find a convenient way of
calling something in a standard module that will accomplish the same thing.
If I do so it trips over the Me in Me.Current, which is understandable since
Current isn't a property of the standard module (or something like that).
Can I handle this in a standard module that I could call from different
forms, or do I need to copy and past the code to the current event of
various forms?
associated code, over and over. I have seen the recommendation to use a
standard module for such things, but am not sure I am implementing it
properly. To use a simple example, the code to go to the next record
(command button Click event) is:
DoCmd.GoToRecord , , acNext
That line of code is in a public function named TheNextRecord in the code
module. In the command button's Click event line I put:
=TheNextRecord()
That works, but I don't know if it is the best way to do this. There is
error handling in the functions.
Where this doesn't work is in my code for custom navigation buttons. In the
form's Current event I have (in part):
Dim strCurrent As String
strCurrent = Me.CurrentRecord
This is the beginning of code to put the current and total records into a
text box (e.g. Record 1 of 3). However, I cannot find a convenient way of
calling something in a standard module that will accomplish the same thing.
If I do so it trips over the Me in Me.Current, which is understandable since
Current isn't a property of the standard module (or something like that).
Can I handle this in a standard module that I could call from different
forms, or do I need to copy and past the code to the current event of
various forms?