Input masks not working (1 Viewer)

access2010

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 26, 2009
Messages
1,021
Hello, I have tried the following input masks in Access 2003, and they are not working. Could I please receive a suggestion on how to correct this problem?
===

Entered as = BILL SMITH or bill smith
>L<??????????????
Want = Bill Smith

A first or last name with the first letter automatically capitalized.

Entered as = target $10.00
>L<??????????????
Want = Target $10.00
===

Thank you for your suggestions.
Nicole
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:36
Joined
Oct 29, 2018
Messages
21,467
Hi Nicole. I don't use Input Mask much, so I am not sure if there's a way to do that. However, I know you can easily do that with VBA.
 

isladogs

MVP / VIP
Local time
Today, 02:36
Joined
Jan 14, 2017
Messages
18,216
You need to use the StrConv function as follows (omitting the '?')

Code:
?strconv("yOuR tExt herE",vbProperCase)
Your Text Here

Or you can use the equivalent StrConv value 3 instead
Code:
?strconv("yOuR tExt herE",3)
Your Text Here

I would use this in the after update event of the form control(s)
I don't think you can do this as an input mask and in my experience many users find them a hindrance
 

ypma

Registered User.
Local time
Today, 02:36
Joined
Apr 13, 2012
Messages
643
Access2010 . When i was using access 2003 i used a Function which was called in the after update event of the field Full-name. I have included it as it answers both of your desired outcomes. This is just another way to skin the cat..

I Know some of the experts will not open attachments, so if the script is required I am happy to post it.
 

Attachments

  • UpperCase sample.mdb
    276 KB · Views: 102

vba_php

Forum Troll
Local time
Yesterday, 20:36
Joined
Oct 6, 2019
Messages
2,880
I Know some of the experts will not open attachments
this is serious anomaly in the technology industry, and in a lot of cases, it is the primary problem in allowing future innovations to happen. It makes me wonder how Steve Jobs handled the problem when he was running Apple for the 2nd time. I would guess he was forced into the position of accepting the legal action against him if something indeed did go wrong with a new implementation. Someone always has to take the blame, and it seems like to me that engineering professionals who work in large corporations reject ideas of new changes because they don't want to be held liable for the unknowns and mishaps that noone knows might exist.

IMO, the solution to this is someone that understands those unknowns and gives the engineers confidence that what they're doing can be figured out! Why do those people NOT exist!? Where is Jobs when we need him? He's probably having a chuckle with the Lord in Heaven because noone has been able to take his place and carry on! :p
 

moke123

AWF VIP
Local time
Yesterday, 21:36
Joined
Jan 11, 2013
Messages
3,915
@Adam
Whats Steve Jobs got to do with not opening attachments. I'm sure any reluctance to opening attachments is related to rogue code that may have adverse consequences.

@ypma
Dev Ashish had code posted from Jay Holovacs that was very simiar. One problem I had with it was last names such as LeBlanc or DuRivage would be Leblanc or Durivage. I like the message box approach that gives you an option. I'm going to experiment with it. Thanks.
 

ypma

Registered User.
Local time
Today, 02:36
Joined
Apr 13, 2012
Messages
643
vba_php: Not sure why you appear to have a dig at my post. It was posted as an alternative . If you have some constructive criticism i am always willing to learn.

Ypma
 

vba_php

Forum Troll
Local time
Yesterday, 20:36
Joined
Oct 6, 2019
Messages
2,880
vba_php: Not sure why you appear to have a dig at my post. It was posted as an alternative . If you have some constructive criticism i am always willing to learn.
no it's not a dig! why would you think that? I was using your information to open the eyes of people who have narrow views. don't see it that way dude! this post of yours is unfortunately just another instance of my words being misinterpreted. I'm sure you understand, right? I'm sure you're a smart guy.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 02:36
Joined
Jul 9, 2003
Messages
16,280
vba_php: Not sure why you appear to have a dig at my post. It was posted as an alternative . If you have some constructive criticism i am always willing to learn.



Ypma

I don't think you will get much in the way of "constructive" from Adam, (vba_php) he's a bit of a loose canon....

Sent from Newbury UK
 

ypma

Registered User.
Local time
Today, 02:36
Joined
Apr 13, 2012
Messages
643
Moke123 : Thank you for you comments you hit the nail on the head , point taken, i was just addressing the two desired outcome requested. Will also test further.



Regards Ypma
 

moke123

AWF VIP
Local time
Yesterday, 21:36
Joined
Jan 11, 2013
Messages
3,915
@ypma

You welcome.

I'm playing around as we speak to add a function to detect a capital letter within the string and keep it if appropriate.
 

isladogs

MVP / VIP
Local time
Today, 02:36
Joined
Jan 14, 2017
Messages
18,216
Hi ypma
Your code does a similar job to using the built-in StrConv function with the vbProperCase argument...though with a lot more code!

In fact, as moke observed, it has the same disadvantages e.g.
Code:
?strconv("matt leblanc",vbProperCase)
Matt Leblanc

Just wondering whether your code has any benefits not covered in StrConv.

Moke
Not sure how you could 100% reliably distinguish when a capital letter is needed in the middle of a word.
For example, whilst it should be Matt LeBlanc, Stephen Lebans is correctly capitalised
 

vba_php

Forum Troll
Local time
Yesterday, 20:36
Joined
Oct 6, 2019
Messages
2,880
I don't think you will get much in the way of "constructive" from Adam, (vba_php) he's a bit of a loose canon....
hmmm....it's possible Tony. But the split is always 50/50 with regard to viewpoints from outsiders. I won't talk anymore in this thread...I don't wanna hijack it.
 

ypma

Registered User.
Local time
Today, 02:36
Joined
Apr 13, 2012
Messages
643
IsladDogs: Fair comment, however it does recognise o'brian and changes it to O'Brian . Also macdonald becomes MacDonald.

# If Mid$(strUpper, I, 3) = "mac" Then
' Make the "M" upper case
Mid$(strUpper, I, 1) = UCase$(Mid$(strUpper, I, 1))
intSkip = 2 ' and set up to skip the next 2 characters
End If#

Could not more if statements, be added to cover more eventualities ?

Just curious

Regards Ypma
 

Gasman

Enthusiastic Amateur
Local time
Today, 02:36
Joined
Sep 21, 2011
Messages
14,265
Here is something I found that covered all the names I was entering.
However it does not do LeBlanc or DuSavage.

As there can be so many variations I would have thought a table with lowercase version and correct case version would be the way to go.?

Then one could just add leblanc and dusavage and be done with it.?

HTH

Code:
'************** 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 mixed_case(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
        mixed_case = ""
        Exit Function
    End If
    str = Trim(str) 'added 11/22/98
    If Len(str) = 0 Then
        mixed_case = ""
        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
        mixed_case = 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
    mixed_case = ts
End Function
Private Sub Special_Name(str As String, ps As Integer)
'expects str to be a lower case string, ps to be the
'start of name to check, returns str modified in place
'modifies the internal character (not the initial)
Dim iLen As Integer

Dim char2 As String
char2 = Mid$(str, ps, 2) 'check for Scots Mc
If (char2 = "mc") And Len(str) > ps + 1 Then '3rd char is CAP
    Mid$(str, ps + 2) = UCase$(Mid$(str, ps + 2, 1))
End If

char2 = Mid$(str, ps, 2) 'check for ff
If (char2 = "ff") And Len(str) > ps + 1 Then 'ff form
    Mid$(str, ps, 2) = LCase$(Mid$(str, ps, 2))
End If

'char2 = Mid$(str, ps + 1, 1) 'check for apostrophe as 2nd char
'If (char2 = "'") Then '3rd char is CAP
'    Mid$(str, ps + 2) = UCase$(Mid$(str, ps + 2, 1))
'End If

' Allow for a ' anywhere and then UCASE the next character
' Added by Paul Steel based on code above

For iLen = ps To Len(str)
    char2 = Mid$(str, iLen, 1) 'check for apostrophe
    If (char2 = "'") Then 'next char is CAP
        Mid$(str, iLen + 1) = UCase$(Mid$(str, iLen + 1, 1))
    End If
Next

Dim char3 As String
char3 = Mid$(str, ps, 3) 'check for scots Mac
If (char3 = "mac") And Len(str) > ps + 1 Then 'Mac form
    Mid$(str, ps + 3) = UCase$(Mid$(str, ps + 3, 1))
End If

Dim char4 As String
char4 = Mid$(str, ps, 4) 'check for Fitz
If (char4 = "fitz") And Len(str) > ps + 1 Then 'Fitz form
    Mid$(str, ps + 4) = UCase$(Mid$(str, ps + 4, 1))
End If

End Sub
Private Function first_letter(str As String, ps As Integer) As Integer
'ps=starting point to search (starts with character AFTER ps)
'returns next first letter, 0 if no more left
'modified 6/18/99 to handle hyphenated names
Dim p2 As Integer, p3 As Integer, s2 As String
    s2 = str
    p2 = InStr(ps, str, " ") 'points to next blank, 0 if no more
    p3 = InStr(ps, str, "-") 'points to next hyphen, 0 if no more
    If p3 <> 0 Then
        If p2 = 0 Then
            p2 = p3
        ElseIf p3 < p2 Then
            p2 = p3
        End If
    End If
    If p2 = 0 Then
        first_letter = 0
        Exit Function
    End If
    'first move to first non blank, non punctuation after blank
    While is_alpha(Mid$(str, p2)) = False
        p2 = p2 + 1
        If p2 > Len(str) Then 'we ran off the end
            first_letter = 0
            Exit Function
        End If
    Wend
    first_letter = p2
End Function
Public Function is_alpha(ch As String)
'returns true if this is alphabetic character
'false if not
    Dim c As Integer
    c = Asc(ch)
    Select Case c
        Case 65 To 90
            is_alpha = True
        Case 97 To 122
            is_alpha = True
        Case Else
            is_alpha = False
    End Select
    
End Function
Private Function is_roman(str As String, ps As Integer) As Integer
'starts at position ps, until end of word. If it appears to be
'a roman numeral, than the entire word is capped in passed back
'string, else no changes made in string
'returns 1 if changes were made, 0 if no change
Dim mx As Integer, p2 As Integer, flag As Integer, i As Integer
    mx = Len(str) 'just so we don't go off the edge
    p2 = InStr(ps, str, " ") 'see if there is another space after this word
    If p2 = 0 Then
        p2 = mx + 1
    End If
    'scan to see if any inappropriate characters in this word
    flag = 0
    For i = ps To p2 - 1
        If InStr("ivxIVX", Mid$(str, i, 1)) = 0 Then
            flag = 1
        End If
    Next i
    If flag Then
        is_roman = 0
        Exit Function 'this is not roman numeral
    End If
    Mid$(str, ps) = UCase$(Mid$(str, ps, p2 - ps))
    is_roman = 1
End Function
'************** Code End  *************
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 21:36
Joined
Jan 23, 2006
Messages
15,378
There was a function fProperCase on the forum years ago trying to address the Name and proper case and the various exceptions. As was agreed then, it's a start especially if the exceptions are few. Many programmers have spent careers trying to resolve the names and addresses formatting/presentation variants. If you have a procedure that works for you, then go with it--but watch for exceptions.

A Google search will find lots of people who looked and/or are still looking for
a good proper case algorithm.

Good luck.
 
Last edited:

access2010

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 26, 2009
Messages
1,021
Thank you ALL for your suggestions and we have spent most of the weekend trying to get the data in the fields to upper and lower cases, without any success.

If we could please receive in our attached database a working Upper and Lower Case field we would appreciate it.

Thank you,
Crystal
 

Attachments

  • Upper_Lower_Case_2019_Dec29.mdb
    252 KB · Views: 104

moke123

AWF VIP
Local time
Yesterday, 21:36
Joined
Jan 11, 2013
Messages
3,915
Moke
Not sure how you could 100% reliably distinguish when a capital letter is needed in the middle of a word.
For example, whilst it should be Matt LeBlanc, Stephen Lebans is correctly capitalised

The code I've been using for years is that which Gasman posted.
The problem isnt really about misspelling the name, its about spelling the name correctly. I use that code in the afterupdate event of the textbox. If you spell the name leBlanc or LeBlanc it will always return Leblanc. You cant make the correction because every time you try the afterupdate event fires and your back to Leblanc. I've got something working but needs some tweaking. I'll post it when done.
 

Users who are viewing this thread

Top Bottom