From: Irshad Alam on
I have field on the form named Model, in which I want to change last 3
alphabet to capital, generall the data entry is like below :

wa470 llc
wa420
3bc

So, I tried to apply the below, which gives no result (no error or show no
change)


Private Sub Model_AfterUpdate()
Dim last3 As String
last3 = right(Me.Model, 3)
If right(Me.Model, 3) = "llc" Then
UCase (last3)
End If
End Sub

Please advice

Regards

Irshad

From: Rob Parker on
Instead of UCase (last3), use UCase (right(Me.Model, 3))

You don't need to use the local variable last3 at all; and because your If
statement is a single line, you can simplify your code to:
Private Sub Model_AfterUpdate()
If right(Me.Model, 3) = "llc" Then UCase (right(Me.Model, 3))
End Sub

HTH,

Rob


"Irshad Alam" <IrshadAlam(a)discussions.microsoft.com> wrote in message
news:79C221B6-3818-4E5B-A2D3-56E83EE0C56A(a)microsoft.com...
>I have field on the form named Model, in which I want to change last 3
> alphabet to capital, generall the data entry is like below :
>
> wa470 llc
> wa420
> 3bc
>
> So, I tried to apply the below, which gives no result (no error or show no
> change)
>
>
> Private Sub Model_AfterUpdate()
> Dim last3 As String
> last3 = right(Me.Model, 3)
> If right(Me.Model, 3) = "llc" Then
> UCase (last3)
> End If
> End Sub
>
> Please advice
>
> Regards
>
> Irshad
>

From: Irshad Alam on
Dear Sir,

I tried the code below as advised,

Private Sub Model_AfterUpdate()
If right(Me.Model, 3) = "llc" Then UCase (right(Me.Model, 3))
End Sub

It makes no difference/changes not even produces error, the text stays as it
is.

I tried on change event also, but same result.

Please check and advice.

Regards

Irshad


"Rob Parker" wrote:

> Instead of UCase (last3), use UCase (right(Me.Model, 3))
>
> You don't need to use the local variable last3 at all; and because your If
> statement is a single line, you can simplify your code to:
> Private Sub Model_AfterUpdate()
> If right(Me.Model, 3) = "llc" Then UCase (right(Me.Model, 3))
> End Sub
>
> HTH,
>
> Rob
>
>
> "Irshad Alam" <IrshadAlam(a)discussions.microsoft.com> wrote in message
> news:79C221B6-3818-4E5B-A2D3-56E83EE0C56A(a)microsoft.com...
> >I have field on the form named Model, in which I want to change last 3
> > alphabet to capital, generall the data entry is like below :
> >
> > wa470 llc
> > wa420
> > 3bc
> >
> > So, I tried to apply the below, which gives no result (no error or show no
> > change)
> >
> >
> > Private Sub Model_AfterUpdate()
> > Dim last3 As String
> > last3 = right(Me.Model, 3)
> > If right(Me.Model, 3) = "llc" Then
> > UCase (last3)
> > End If
> > End Sub
> >
> > Please advice
> >
> > Regards
> >
> > Irshad
> >
>
> .
>
From: DrGUI on
Try:

Me.Model.Value = Left(Me.Model.Value, Len(Me.Model.Value) - 3) &
UCase(Right(Me.Model.Value, 3))





"Irshad Alam" wrote:

> I have field on the form named Model, in which I want to change last 3
> alphabet to capital, generall the data entry is like below :
>
> wa470 llc
> wa420
> 3bc
>
> So, I tried to apply the below, which gives no result (no error or show no
> change)
>
>
> Private Sub Model_AfterUpdate()
> Dim last3 As String
> last3 = right(Me.Model, 3)
> If right(Me.Model, 3) = "llc" Then
> UCase (last3)
> End If
> End Sub
>
> Please advice
>
> Regards
>
> Irshad
>
From: John W. Vinson on
On Sun, 21 Feb 2010 22:37:01 -0800, Irshad Alam
<IrshadAlam(a)discussions.microsoft.com> wrote:

>I have field on the form named Model, in which I want to change last 3
>alphabet to capital, generall the data entry is like below :
>
>wa470 llc
>wa420
>3bc
>
>So, I tried to apply the below, which gives no result (no error or show no
>change)
>
>
>Private Sub Model_AfterUpdate()
>Dim last3 As String
>last3 = right(Me.Model, 3)
>If right(Me.Model, 3) = "llc" Then
>UCase (last3)
>End If
>End Sub
>
>Please advice
>
>Regards
>
>Irshad

You're misunderstanding how UCase() works. It doesn't change anything in your
form or in your table; it is just a function that returns a value. Try typing
Ctrl-G and type:

?Ucase("llc")

in the Immediate window and you'll see.

To change the value in the textbox, you must explicitly set the textbox to an
expression, e.g.

Private Sub Model_AfterUpdate()
If Right(Me!Model, 3) = "llc" Then
Me!Model = Left(Me!Model, Len(Me!Model) - 3) & "LLC"
End If
End Sub

--

John W. Vinson [MVP]