Solved Numbers & UpperCase (1 Viewer)

A17BPG

New member
Local time
Yesterday, 16:02
Joined
Mar 30, 2018
Messages
23
Hi Everybody I am trying to enter a line of code that allows me to input the house number in a text box followed by the street name, but want the first character of street name to be in UpperCase. Has anyone any suggestions on coding I can use.

Thanks Brian (A17BPG)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:02
Joined
Feb 19, 2013
Messages
16,706
Investigate using the proper function

proper (“hello”)

will return “Hello”
 

Eugene-LS

Registered User.
Local time
Today, 02:02
Joined
Dec 7, 2018
Messages
484
but want the first character of street name to be in UpperCase
Try the code below:
Code:
Dim sVal$
    sVal = "I am trying to enter a line of code that allows me to input the house number in a text box followed by the street name"
    
    sVal = StrConv(sVal, vbUpperCase)
    Debug.Print sVal
    
    sVal = StrConv(sVal, vbLowerCase)
    Debug.Print sVal
    
    sVal = StrConv(sVal, vbProperCase) 'That one
    Debug.Print sVal
It will print text in Immediate Window (Ctrl+G):
Code:
I AM TRYING TO ENTER A LINE OF CODE THAT ALLOWS ME TO INPUT THE HOUSE NUMBER IN A TEXT BOX FOLLOWED BY THE STREET NAME
i am trying to enter a line of code that allows me to input the house number in a text box followed by the street name
I Am Trying To Enter A Line Of Code That Allows Me To Input The House Number In A Text Box Followed By The Street Name
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:02
Joined
Feb 19, 2013
Messages
16,706
ah yeah - forgot I use a function called 'proper' - which uses strConv:(
 

strive4peace

AWF VIP
Local time
Yesterday, 18:02
Joined
Apr 3, 2020
Messages
1,002
fi Brian @A17BPG

try this in the control AfterUpdate event:
Rich (BB code):
With Me.ActiveControl
   If IsNull(.Value) Then
      Exit Sub
   Else
      .Value = StrConv(.Value,vbProperCase)
   End If
End With

it won't change anything until they're done editing the value
 

A17BPG

New member
Local time
Yesterday, 16:02
Joined
Mar 30, 2018
Messages
23
Hi Everybody I am trying to enter a line of code that allows me to input the house number in a text box followed by the street name, but want the first character of street name to be in UpperCase. Has anyone any suggestions on coding I can use.

Thanks Brian (A17BPG)
Hi Thanks for reply's I have tried the "ProperCase" Command with the result (Compile Error - Sub or Function not Defined).
The code using :

Private Sub txtAddress1_AfterUpdate()

Me.txtAddress1 = propercase(txtAddress1, 1)

End Sub

Thanks Brian (a17BPG)
 

A17BPG

New member
Local time
Yesterday, 16:02
Joined
Mar 30, 2018
Messages
23
fi Brian @A17BPG

try this in the control AfterUpdate event:
Rich (BB code):
With Me.ActiveControl
   If IsNull(.Value) Then
      Exit Sub
   Else
      .Value = StrConv(.Value,vbProperCase)
   End If
End With

it won't change anything until they're done editing the value
Hi thanks for code work great.

Thanks again Brian (A17BPG)
 

Eugene-LS

Registered User.
Local time
Today, 02:02
Joined
Dec 7, 2018
Messages
484
try this in the control AfterUpdate event:
Rich (BB code):
Code:
[COLOR=Blue]With[/COLOR] Me.ActiveControl
   [COLOR=Blue]If[/COLOR] IsNull(.Value) [COLOR=Blue]Then[/COLOR]
      [COLOR=Blue]Exit Sub[/COLOR]
   [COLOR=Blue]Else[/COLOR]
      .Value = StrConv(.Value,vbProperCase)
   [COLOR=Blue]End If
End With[/COLOR]
Shorter way:
Code:
Private Sub ControlName_AfterUpdate
         Me.ControlName = StrConv(Me.ControlName & "", vbProperCase)
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:02
Joined
Feb 19, 2013
Messages
16,706
only problem with that is it will populate the field with a zls whereas with the other solution, nulls will stay as nulls
 

strive4peace

AWF VIP
Local time
Yesterday, 18:02
Joined
Apr 3, 2020
Messages
1,002
Hi thanks for code work great.

Thanks again Brian (A17BPG)
you're welcome, Brian ~ happy to help

btw, if you use StrConv in a query, the query doesn't understand the vbProperCase constant so you have to use its value, 3

in a query:
Code:
CalculatedFieldname: StrConv( [fieldname], 3)
 
Last edited:

Users who are viewing this thread

Top Bottom