Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2005, 06:43 AM
Authorized User
 
Join Date: Feb 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok.. did that..

When I ran the query on the data that causes the error I got:

Unexpected Error Message

Error 5 Occured
Invalid proedure call or argument

cLetter value:
cLetterASC Value:77

and the same for Value:67 and Value:79

What does this mean?

 
Old May 19th, 2005, 07:29 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

It looks like the ASC value remains unchanged from the previous character. The cLetter variable is Empty???? I think that a non standard character has been put in the cLetter variable, the next line tries to get the ASC number and fails because of this.

The function needs to recognise standard and non-standard ASCII characters before the ASC function call.I am looking into how to do this. Perhaps a member here can advise how to do this. I will put up a new post.

Jon

 
Old May 23rd, 2005, 04:20 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Akb786,

Put this check in between the two variable assignements.

    cLetter = Mid(strText, L, 1)
If IsNull(cLetter) Then
        FindUppers = False
        Exit Function
    end if

    cLetterASC = Asc(cLetter)

Don't forget, add this to both of these Sections in the routine.

Jon

 
Old May 23rd, 2005, 05:02 AM
Authorized User
 
Join Date: Feb 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,

It still does the same thing..

code now is:

Function FindUppers(strText As String, WholeWordOnly As Boolean) As Boolean
On Error GoTo ErrTrap

Dim cLetter As String
Dim cLetterASC As Long
Dim cWord As Boolean

Dim L As Integer

For L = 2 To Len(strText)

    cLetter = Mid(strText, L, 1)
    If IsNull(cLetter) Then
        FindUppers = False
        Exit Function
    End If
    cLetterASC = Asc(cLetter)

    Select Case cLetterASC
        Case 65 To 90 'Cap Found
            If WholeWordOnly Then

                'And check that the letter is not an I
                If Asc(Mid(strText, i + 1, 1)) <> 73 Then
                    Select Case Asc(Mid(strText, i + 1, 1))
                        Case 32, 33, 44, 45, 46, 47, 58, 59, 63, 95
                            Exit Function
                    End Select
                End If

                L = L + 1 'Next Letter
                'Loop forward through the rest of the word. If a lowercase is found then clear the cWord var
                Do While i < Len(strText)

                    cLetter = Mid(strText, L, 1)
                    If IsNull(cLetter) Then
                    FindUppers = False
                    Exit Function
                    End If
                    cLetterASC = Asc(cLetter)

                    Select Case cLetterASC
                        Case 32, 33, 44, 45, 46, 47, 58, 59, 63, 95
                            L = L - 1 'Move back one letter so Current L is examined (punctuation,space)
                            Exit Do
                        Case Else
                            If cLetterASC >= 65 And cLetterASC <= 90 Then
                                cWord = True
                            Else
                                cWord = False
                                Exit Do
                            End If
                    End Select
                    L = L + 1 'Next Letter
                Loop
            Else 'Find a Partially Capped word with no punctuation preceding and NOT full capped word
                i = L - 1

                'First Check that next letter (+2) is not uppercase
                If Asc(Mid(strText, i + 2, 1)) >= 65 And Asc(Mid(strText, i + 2, 1)) <= 90 Then Exit Function
                'And check thet the letter is not an I
                If Asc(Mid(strText, i + 1, 1)) = 73 Then Exit Function

                Do While i >= 1

                    cLetter = Mid(strText, i, 1)
                    If IsNull(cLetter) Then
                    FindUppers = False
                    Exit Function
                    End If
                    cLetterASC = Asc(cLetter)

                    Select Case cLetterASC
                        Case 32
                            'Do nothing
                        Case 33, 44, 45, 46, 47, 58, 59, 63, 95 'Punctuation
                            Exit Do
                        Case Else
                            cWord = True
                            Exit Do
                    End Select
                    i = i - 1 'Next Letter
                Loop
            End If

        Case 32, 33, 44, 45, 46, 47, 58, 59, 63, 95
            'Check that the cWord variable has not been previously populated (Whole Word)
            If cWord Then
                FindUppers = True
                Exit Function
            End If
    End Select
Next L

If cWord Then FindUppers = True
ExitTrap:
 Exit Function
ErrTrap:
    If Err.Number <> 0 Then
   'Debug.Print cLetter & ", ASC value:" & cLetterASC
    MsgBox "Error #" & Err.Number & " Occurred " & vbCr & Err.Description & vbCr & vbCr & "cLetter value:" & cLetter & vbCr & vbCr & "cLetterASC Value:" & cLetterASC _
    , vbExclamation + vbOKOnly _
    , "Unexpected Error" _
    , Err.HelpFile _
    , Err.HelpContext
    Resume ExitTrap
    End If
End Function




 
Old May 23rd, 2005, 05:12 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this -

    cLetter = Empty
    cLetter = Mid(strText, L, 1)
    If IsEmpty(cLetter) Then
        FindUppers = False
        Exit Function
    End If
    cLetterASC = Asc(cLetter)


 
Old May 23rd, 2005, 05:41 AM
Authorized User
 
Join Date: Feb 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Same again..

 
Old May 23rd, 2005, 07:44 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

PMJIH (pardon my jumping in here)

Aren't you going to a lot of trouble when you're converting Asc?

Why not use the UCase and LCase commands in your comparisons? And don't forget to remove the "Option Compare Database" from the module -- otherwise case tests don't matter!

To see if the string has uppercase at all, use this statement:
Code:
findUpper = (LCase(TheString) <> TheString)
Then to find your uppercase word, as you are walking throught the string one letter at a time use a test like:
Code:
if Mid(TheString,i,1) >= "A" and (Mid(TheString,i,1) <= "Z") then
    ' this is an uppercase letter
end if
Definitely be sure to remove the "Option Compare Database"!

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I open access DB stored in CD from VB Andraw Pro VB Databases 1 August 14th, 2008 10:05 AM
How to connect to Access db thru VB.NET? am_kuthus Visual Studio 2008 1 June 3rd, 2008 04:48 AM
Connecting to Access 20007 DB with vb.net JohnBoy VB.NET 1 May 21st, 2008 01:26 PM
CAPTION OF ACCESS DB IN VB akash VB How-To 5 March 8th, 2007 11:01 PM
New in .Net VB but learning datareader, access DB tjgrindsted ASP.NET 2.0 Basics 2 February 6th, 2007 08:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.