De-select default value

  • Thread starter Thread starter Joanne
  • Start date Start date
J

Joanne

I have this coding (which was given to me by MVP\ in this forum,
thank you very much) in a txtbox that has '-B/O' as it's default value

Private Sub TxtPoNo_AfterUpdate()
Const strAddText As String = "-B/O"
If Right(Me.txtPoNo.Value, Len(strAddText)) <> strAddText Then _
Me.txtPoNo.Value = Me.txtPoNo.Value & strAddText
End Sub

The problem is that when I tab into the control, the default value is
highlighted, so when I start to type the numbers to preceed the
default value, the default value gets deleted.

Could someone please tell me how to 'de-select' the default value on
entering the control so it doesn't disappear on me?

Thanks for your time
Joanne
 
Joanne said:
I have this coding (which was given to me by MVP\ in this forum,
thank you very much) in a txtbox that has '-B/O' as it's default value

Private Sub TxtPoNo_AfterUpdate()
Const strAddText As String = "-B/O"
If Right(Me.txtPoNo.Value, Len(strAddText)) <> strAddText Then _
Me.txtPoNo.Value = Me.txtPoNo.Value & strAddText
End Sub

The problem is that when I tab into the control, the default value is
highlighted, so when I start to type the numbers to preceed the
default value, the default value gets deleted.

Could someone please tell me how to 'de-select' the default value on
entering the control so it doesn't disappear on me?

Thanks for your time
Joanne

Use .SelStart and set it to Len$(ValueInControl)+1
 
Hi -

The entire field is being selected because your options setting
Tools - Options - Keyboard - Behaviour Entering Field
is set to Select Entire Field.

You can either change the option setting (which will affect every field
on every form you use), or you can put this in the On Got Focus event of
the control:

me![controlname].selstart = 0

which overrides the entire field selection, and puts the cursor at the
beginning of the text.

HTH

John
 
Back
Top