I have a Form named "fNavButtons" used as a SubForm in control named "subformNavButtons". subformNavButtons is a control on my main form named "fAAA".
fNavButtons has 2 CommandButtons, cmdNextRec and cmdPrevRec. These are on a subform to allow an AutoRepeat to continue when form fAAA gets another record.
If I am at the first record, I want cmdPrevRec.Enabled = False, and if I am at the last record, cmdNextRec.Enabled = False. Otherwise the command buttons are .Enabled = True.
The problem is that with filters I can have one record, and therefore both need to be .Enabled = False. I can't seem to assign .Enabled = False for both simultaneously. This would mean the subform has no control enabled. I get run-time error 2164 - You can't disable a control while it has the focus on the 3rd line of the code below.
Expand|Select|Wrap|Line Numbers
- . . .
- Forms!fAAA.SetFocus
- Forms!fAAA!txtTitleName.SetFocus
- Forms!fAAA!subformNavButtons.Form!cmdNextRec.Enabled = False
If I remove the 4th line of code, the focus is actually at txtTitleName, and keyboard entries go to that control. Good, but I still have an enabled control that should be .Enabled = False