Hi to all,
Can have these two lines of VBA code in a one line?
Code:Me.txtFamilyName = Trim(Me.txtFamilyName) Me.txtFamilyName = UCase(Left(Me.txtFamilyName, 1)) & Mid(Me.txtFamilyName, 2)
Thanks
Khalil
Hi to all,
Can have these two lines of VBA code in a one line?
Code:Me.txtFamilyName = Trim(Me.txtFamilyName) Me.txtFamilyName = UCase(Left(Me.txtFamilyName, 1)) & Mid(Me.txtFamilyName, 2)
Thanks
Khalil
I believe you could use a : to seperate them, but that to me would make it harder to read?
Write your code so that it is easy for ANYONE to understand it.![]()
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Can use Trim() on each instance of txtFamilyName in the second expression.
Why is Trim needed? Are there leading spaces in data? I suppose users could mistype and cause that.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Right. The trim is to remove any leading spaces.
you could use
Me.txtFamilyName = UCase(Left(trim(Me.txtFamilyName), 1)) & Mid(trim(Me.txtFamilyName), 2)
but it is a bit less readable
Perhaps
That is one line?Code:Me.txtFamilyName = strConv(Me.txtFamilyName,vbProperCase)
A lot easier to read as well?![]()
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Hi,
Thank you all.
Solved
So with Trim:
Code:Me.txtFamilyName = strConv(Trim(Me.txtFamilyName), vbProperCase) or Me.txtFamilyName = Trim(strConv(Me.txtFamilyName, vbProperCase))
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.