propercase doesn't work

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
501
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I do not understand why this code won't work in my textbox on Access userform.

VBA Code:
Option Compare Database

Private Sub FirstName_Change()
   Me.FirstName.Value = StrConv(Me.FirstName.Value, vbProperCase)
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

jackd

Well-known Member
Joined
Oct 19, 2006
Messages
1,376
Office Version
  1. 365
What did you expect this to do? this code won't work

From Microsoft textbox change

Changing the data in a text box or combo box by using the keyboard causes keyboard events to occur in addition to control events like the Change event. For example, if you move to a new record and type an ANSI character in a text box in the record, the following events occur in this order:


KeyDownKeyPressBeforeInsertChangeKeyUp

The BeforeUpdate and AfterUpdate events for the text box or combo box control occur after you have entered the new or changed data in the control and moved to another control (or clicked Save Record on the Records menu), and therefore after all of the Change events for the control.
 

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
501
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Whatever is typed into the textbox. I wanted to capitalize the first letter that is entered.
 

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
501
Office Version
  1. 365
  2. 2010
Platform
  1. Windows

ADVERTISEMENT

When does that event trigger? Because I don't see doing anything.
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
2,440
Office Version
  1. 365
Platform
  1. Windows
I do not understand why this code won't work in my textbox on Access userform.
Because at the moment you type a character the control value is null.


When does that event trigger? Because I don't see doing anything.
That was explained in post 2.

If you cannot use AfterUpdate then IMO you will have to use a key event for the control - possibly KeyUp. You'll have to add code to move to the end of whatever is typed in because the cursor will jump to the beginning of the word when you update after every key stroke - probably will look funny to anyone watching. Also, I think you will have to use the control's Text property because of the Null thing. Best to let the value update when focus moves off of the control.
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
2,440
Office Version
  1. 365
Platform
  1. Windows
Actually, it looks OK on my laptop. Something like

VBA Code:
Private Sub Text0_KeyUp(KeyCode As Integer, Shift As Integer)
Me.Text0.Text = StrConv(Me.Text0.Text, vbProperCase)
Me.Text0.SelStart = Len(Me.Text0.Text)
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,109
Messages
5,768,144
Members
425,458
Latest member
Jaspal1996

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top