Solved Numbers & UpperCase

A17BPG

New member
Local time
Yesterday, 21:29
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)
 
Investigate using the proper function

proper (“hello”)

will return “Hello”
 
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
 
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 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)
 
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)
 
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
 
only problem with that is it will populate the field with a zls whereas with the other solution, nulls will stay as nulls
 
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

Back
Top Bottom