Group:  Microsoft Access ยป microsoft.public.access.reports
Thread: Default Value

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Default Value
Joanne <jobobbuss[ at ]sbcglobal.com> 24.09.2006 16:56:54
I have a field that I would like to have this in as it's default
value:

-B/O

Then when the user goes to the field I would like them to be able to
add a numeric string in front of this default, something like this:

239401-B/O

I am simply trying to save some repetitive keyboarding.

Any help is as always appreciated. Finding that someone has read and
answered your question is a lot like getting a surprise gift.

You mvps/contributors are great

Joanne
Re: Default Value
"Ken Snell \(MVP\)" <kthsneisllis9[ at ]ncoomcastt.renaetl> 24.09.2006 17:08:37
You can't do this in a report, so I assume that you want to do it in a form?

One way is to use the AfterUpdate event of the textbox to add the trailing
text to whatever the user enters:

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


Or you can put the default text in the textbox and then position the cursor
to the left of the first character, using the GotFocus event of the textbox:

Private Sub TextBoxName_GotFocus()
Const strAddText As String = "-B/O"
If Len(Me.TextBoxName.Value & "") = 0 Then
Me.TextBoxName.Value = strAddText
Me.TextBoxName.SelStart = 0
Me.TextBoxName.SelLength = 0
End If
End Sub

--

Ken Snell
<MS ACCESS MVP>


"Joanne" <jobobbuss[ at ]sbcglobal.com> wrote in message
news:OXLdyp$3GHA.508[ at ]TK2MSFTNGP06.phx.gbl...
[Quoted Text]
>I have a field that I would like to have this in as it's default
> value:
>
> -B/O
>
> Then when the user goes to the field I would like them to be able to
> add a numeric string in front of this default, something like this:
>
> 239401-B/O
>
> I am simply trying to save some repetitive keyboarding.
>
> Any help is as always appreciated. Finding that someone has read and
> answered your question is a lot like getting a surprise gift.
>
> You mvps/contributors are great
>
> Joanne


Re: Default Value
Joanne <jobobbuss[ at ]sbcglobal.com> 24.09.2006 19:43:07
Works like a charm - thank you
MVP\ wrote:

[Quoted Text]
>You can't do this in a report, so I assume that you want to do it in a form?
>
>One way is to use the AfterUpdate event of the textbox to add the trailing
>text to whatever the user enters:
>
>Private Sub TextBoxName_AfterUpdate()
>Const strAddText As String = "-B/O"
>If Right(Me.TextBoxName.Value, Len(strAddText)) <> strAddText Then _
> Me.TextBoxName.Value = Me.TextBoxName.Value & strAddText
>End Sub
>
>
>Or you can put the default text in the textbox and then position the cursor
>to the left of the first character, using the GotFocus event of the textbox:
>
>Private Sub TextBoxName_GotFocus()
>Const strAddText As String = "-B/O"
>If Len(Me.TextBoxName.Value & "") = 0 Then
> Me.TextBoxName.Value = strAddText
> Me.TextBoxName.SelStart = 0
> Me.TextBoxName.SelLength = 0
>End If
>End Sub
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net