dbTalk Databases Forums  

UpperCase to ProperCase and Back again

comp.databases.ms-access comp.databases.ms-access


Discuss UpperCase to ProperCase and Back again in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bobdydd
 
Posts: n/a

Default UpperCase to ProperCase and Back again - 12-17-2011 , 01:09 AM






Hi

I am trying to find a way to change a text field from UpperCase
To ProperCase and back again with another doubleclick but it is not
working.

Can anyone help?
Thanks

Private Sub txtVenueProductTitle_DblClick(Cancel As Integer)
If IsNull(Me.txtVenueProductTitle) Then
MsgBox "Product Title is Empty", vbExclamation, "Oops!"
Me.txtVenueProductTitle.SetFocus
Exit Sub
End If
If Me.txtVenueName = vbUpperCase Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbProperCase)
End If
If Me.txtVenueName = vbProperCase Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbUpperCase)
End If
End Sub

Reply With Quote
  #2  
Old   
Bob Quintal
 
Posts: n/a

Default Re: UpperCase to ProperCase and Back again - 12-17-2011 , 06:13 AM






bobdydd <reallyuseful2004 (AT) yahoo (DOT) co.uk> wrote in
news:dcdecd85-f11f-4a44-ac66-b503f38c3478 (AT) 4g2000yqu (DOT) googlegroups.com:

Quote:
Hi

I am trying to find a way to change a text field from UpperCase
To ProperCase and back again with another doubleclick but it is
not working.

Can anyone help?
Thanks

Private Sub txtVenueProductTitle_DblClick(Cancel As Integer)
If IsNull(Me.txtVenueProductTitle) Then
MsgBox "Product Title is Empty", vbExclamation, "Oops!"
Me.txtVenueProductTitle.SetFocus
Exit Sub
End If
If Me.txtVenueName = vbUpperCase Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle,
vbProperCase) End If
If Me.txtVenueName = vbProperCase Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle,
vbUpperCase) End If
End Sub

As written, if you start with upper case, it works twice first
changing to proper then back to upper, leaving you where you started
in uppercase.

change the code to
If Me.txtVenueName = vbUpperCase Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle,vbProperCase)
ElseIf Me.txtVenueName = vbProperCase Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbUpperCase)
End If



--
Bob Q.
PA is y I've altered my address.

Reply With Quote
  #3  
Old   
Ron Paii
 
Posts: n/a

Default Re: UpperCase to ProperCase and Back again - 12-17-2011 , 06:28 AM



"bobdydd" <reallyuseful2004 (AT) yahoo (DOT) co.uk> wrote

Quote:
Hi

I am trying to find a way to change a text field from UpperCase
To ProperCase and back again with another doubleclick but it is not
working.

What's not working???

Assuming it's not toggling and txtVenueName is a control field. You need to
set txtVenueName to the new setting. Also you should cast txtVenueName to
integer and check for null before comparing it to vbProperCase.

Quote:
Can anyone help?
Thanks

Private Sub txtVenueProductTitle_DblClick(Cancel As Integer)
If IsNull(Me.txtVenueProductTitle) Then
MsgBox "Product Title is Empty", vbExclamation, "Oops!"
Me.txtVenueProductTitle.SetFocus
Exit Sub
End If
If cint(nz(Me.txtVenueName, vbUpperCase)) = vbUpperCase Then
Quote:
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbProperCase)
Me.txtVenuName = vbProperCase

Quote:
End If
'Replacing End if with else will remove the need for the 2nd If.

If cint(nz(Me.txtVenueName, vbLowerCase)) = vbProperCase Then
Quote:
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbUpperCase)
Me.txtVenueName = vbUpperCase

Quote:
End If
End Sub

Reply With Quote
  #4  
Old   
Douglas J Steele
 
Posts: n/a

Default Re: UpperCase to ProperCase and Back again - 12-17-2011 , 06:42 AM



vbUpperCase and vbProperCase are numeric values equal to 1 and 3
respectively. Is that what you're storing in text box txtVenueName?

Assuming it actually contains text, try the following instead:

Private Sub txtVenueProductTitle_DblClick(Cancel As Integer)
If IsNull(Me.txtVenueProductTitle) Then
MsgBox "Product Title is Empty", vbExclamation, "Oops!"
Me.txtVenueProductTitle.SetFocus
Exit Sub
End If

If StrComp(Me.txtVenueName, UCase(Me.txtVenueName), vbBinaryCompare) = 0
Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbProperCase)
Else
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbUpperCase)
End If

End Sub

"bobdydd" wrote in message
news:dcdecd85-f11f-4a44-ac66-b503f38c3478 (AT) 4g2000yqu (DOT) googlegroups.com...

Hi

I am trying to find a way to change a text field from UpperCase
To ProperCase and back again with another doubleclick but it is not
working.

Can anyone help?
Thanks

Private Sub txtVenueProductTitle_DblClick(Cancel As Integer)
If IsNull(Me.txtVenueProductTitle) Then
MsgBox "Product Title is Empty", vbExclamation, "Oops!"
Me.txtVenueProductTitle.SetFocus
Exit Sub
End If
If Me.txtVenueName = vbUpperCase Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbProperCase)
End If
If Me.txtVenueName = vbProperCase Then
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbUpperCase)
End If
End Sub

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.