you can totally Remove the code on the OnCurrent event by Assigning the formula as the
ControlSource of your textbox:
on design view of your form, click on the txtServRecCount textbox and on it's
Property->Data->ControlSource, put:
Code:
=DCount("[CustomerID]", "[xServices]", "[CustomerID]='" & Nz(Me.CustomerID, 0) & "'")
Then remove the code on the Current Event of your form.
With this method, the Textbox is Readonly, so users cannot
change the value in it.
or just add a Caption to your button and on the Activate event,
assign the caption to it as your formula does:
Code:
Private Sub Form_Activate()
Me!TheButtonName.Caption = DCount("[CustomerID]", "[xServices]", "[CustomerID]='" & Nz(Me.CustomerID, 0) & "'")
End Sub
or another possible approach is to Setfocus on Another Control (except the button) on
your form:
Code:
Private Sub Form_Activate()
'set focus on the Counting textbox
Me.txtServRecCount.Setfocus
'set focus on another textbox/control on the form
Me.AnotherTextboxOnForm.Setfocus
End Sub