UpperCase to ProperCase and Back again

B

bobdydd

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
 
B

Bob Quintal

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
 
R

Ron Paii

bobdydd said:
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.
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
Me.txtVenueProductTitle = StrConv(txtVenueProductTitle, vbProperCase)
Me.txtVenuName = vbProperCase

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

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

Douglas J Steele

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top