>>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
[quoted text clipped - 44 lines]
> or directly from an event property:
> SetCurrentRecordNumber(Form)
Thanks for the reply. As the current event (VBA Procedure) of the subform,
the code I have works as intended for identifying the record number and
activating the navigation buttons as needed (for instance, at the first
record the Previous button is disabled). I have copied that code as a
public function, named as you have suggested with frm as Form in
parentheses.
I went to the subform's current event, and tried different combinations
directly on the Current line in the property sheet, which is what I think
you mean by "directly from an event property". As I mentioned earlier, when
I called the function TheNextRecord I did so thus in the command button's
Click event line:
=TheNextRecord()
This worked as intended, but the same syntax did not work for
SetCurrentRecordNumber. I tried it with the = sign, but when I added (Form)
after the function name Access put brackets around it, then had the problem
with the Me in Me.CurrentRecord as I described in my original post (invalid
use of Me keyword). I also tried it with the name of the form, but again
the brackets and the error message. I also tried it with (frm as Form)
exactly as it appears in the function itself, but that was invalid syntax.
I also tried every combination I could think of, but without the = sign.
However, that led to an error message that Access couldn't find the macro
named whatever I put on that line.
What am I missing? Does it make any difference that this is the subform's
Current event rather than a main form's current event?
Marshall Barton - 22 Jun 2006 16:12 GMT
>> BruceM wrote:
>>
[quoted text clipped - 71 lines]
>What am I missing? Does it make any difference that this is the subform's
>Current event rather than a main form's current event?
It sounds like you forgot to change the function's use of Me
to the frm argument, which was the wole purpose of adding
the argument in the first place.
Then function in the standard module will look like:
Public Function SetCurrentRecordNumber(frm As Form)
. . .
something = frm.CurrentRecord
. . .
End Function
The button's OnClick property would then be:
=SetCurrentRecordNumber(Form)

Signature
Marsh
MVP [MS Access]
BruceM - 22 Jun 2006 18:05 GMT
>>> BruceM wrote:
>>>
[quoted text clipped - 96 lines]
>
> =SetCurrentRecordNumber(Form)
Ah! I see. It wasn't that I forgot, but rather that I didn't understand
what I needed to do. I'm starting to see what to do with the parentheses
after the sub or function name. It works as it should now, and I have saved
hours on future projects. Thanks so much.
By the way, when I entered:
=SetCurrentRecordNumber(Form)
Access changed it to:
=SetCurrentRecordNumber([Form])
Is that the expected behavior, or is something amiss? I'm using Access
2000, and I entered that line into the subform's Current event property on
the property sheet.
Marshall Barton - 22 Jun 2006 19:06 GMT
>> BruceM wrote:
>>>> BruceM wrote:
[quoted text clipped - 113 lines]
>2000, and I entered that line into the subform's Current event property on
>the property sheet.
The addition of brackets in control source expressions
(and/or parenthesis in other circumstances) is a (usually?)
harmless habit that Access uses (needed or not) to make sure
names are in a formally correct syntax. The rule for square
brackets is that any name that includes any characters
except alphnumeric or underscorre or starts with a numeric
digit, must be enclosed in [ ]. Access's simple minded
approach to this rule is to make sure everything is
enclosed. While this is normally harmless, you should
double check to make sure that the [ ] don't enclose more
than a single name.

Signature
Marsh
MVP [MS Access]
BruceM - 22 Jun 2006 19:28 GMT
>>> BruceM wrote:
>>>>> BruceM wrote:
[quoted text clipped - 138 lines]
> double check to make sure that the [ ] don't enclose more
> than a single name.
Thanks again. I use only alphanumeric characters and underscores, so I
don't give the brackets much thought except to wonder from time to time why
they are there.
Marshall Barton - 22 Jun 2006 21:28 GMT
>>>> BruceM wrote:
>>>>>> BruceM wrote:
[quoted text clipped - 142 lines]
>don't give the brackets much thought except to wonder from time to time why
>they are there.
You are following the Best Practice recommended by almost
every professional.
Keep up the good work.

Signature
Marsh
MVP [MS Access]
eos - 27 Jun 2006 14:51 GMT
AUTO-REPLY From George Levitt
Please allow this to confirm a system receipt of your e-mail.
I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.
I look forward to replying to your message on Wednesday.
Thanks and warmest regards, George