Full Version: Proper Case
UtterAccess Forums > Microsoft® Access > Access Forms
morpheus
Hello I have a question about my database...
asically it does pritty much anything when I add to it for example it puts everything into proper case and removes underscores and replaces them with spaces etc...
I would like it to apply proper case after it has replaced the underscores with spaces how can I do this?
Its all on frmList...
Many Thanks
James
truittb
Try this.
trconv(replace("your text goes_here","_"," "),vbProperCase)
iandouglas
Or try: -
'************** Code Start *************
'This code was originally written by Jay Holovacs.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Jay Holovacs
'
Public Function ProperCase(str As Variant) As String
'returns modified string, first character of each word us uppercase
'all others lower case
Dim ts As String, ps As Integer, char2 As String
If IsNull(str) Then

Exit Function
End If
str = Trim(str) 'added 11/22/98
If Len(str) = 0 Then
ProperCase = ""
Exit Function
End If
ts = LCase$(str)
ps = 1
ps = first_letter(ts, ps)
special_name ts, 1 'try to fix the beginning
Mid$(ts, 1) = UCase$(left$(ts, 1))
If ps = 0 Then
ProperCase = ts
Exit Function
End If
While ps <> 0
If is_roman(ts, ps) = 0 Then 'not roman, apply the other rules
special_name ts, ps
Mid$(ts, ps) = UCase$(Mid$(ts, ps, 1)) 'capitalize the first letter
End If
ps = first_letter(ts, ps)
Wend
ProperCase = ts
End Function
morpheus
Could I just put the proper case strconv thing under my find and replace statements? there on the after update property?
any Thanks
James
iandouglas
Guess so. Try it as see!
truittb
Yes, just leave out the Replace()
trconv("your text goes_here",vbProperCase)
morpheus
When you say your text goes here what exactly do you mean as I am using the replace function....
If I copy and paste it what would I put in that part could you give me an Example please using the replace function...
Many Thanks
James
truittb
You would put in a literal string, a variable, or a control reference. What replace function are you using?
The first one I posted included the Replace function. The formula replaces the underscore with a space and then applies proper case.
morpheus
Yes but again I would still have to put some text in and I dont know what I would be putting in there..
any Thanks
James
truittb
You would put the text that your search returned. If you want to display it in the textbox do it like this in the recordsource of the textbox.
StrConv(Replace([YourFieldNameHere],"_"," "),vbProperCase)
morpheus
Ok I am putting it on the After Update property of the Subtitle for a test and it comes up with Expected = in the first example...
Here is the database again with the changes... Could you please have a look and let me know the issue please and how I can fix it please...
Many Thanks
James
morpheus
Any Suggestions anyone?
any Thanks
James
morpheus
Does anyone have any ideas for this??
I have tried the code that someone provided (Sorry mate I cant see your post at the moment) and its just not seeming to work...
Many Thanks
James
morpheus
Anyone any idea's?
I am hopless with Visual Basic.
Any advice would be much appreciated.
Thanks
James
morpheus
Anyone know how I could change the code I have been given so that it works?
Thanks
James
morpheus
Does anyone have any suggestions on this issue?
any Thanks
James
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.