Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Coding to count number of letters (2000)

    Hi,
    I have the following coding on an exit control:

    Private Sub CmdExit_Click()
    If IsNull(Me.URN) Then
    MsgBox "Please enter a URN", vbInformation, "NOTE"
    End If
    fOKToClose = True
    Application.Quit
    End Sub

    What I want to be able to check is whether the field URN is Null or has an amount of characters (both numerical & alphabetical) less than or equal to 6. Not too sure how to do this. Any ideas?

  2. #2
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Coding to count number of letters (2000)

    Nigel,

    Try something like this.

    Private Sub CmdExit_Click()
    If IsNull(Me.URN) _
    or len(Me.Urn) <= 6 Then
    MsgBox "Please enter a URN", vbInformation, "NOTE"
    End If
    fOKToClose = True
    Application.Quit
    End Sub
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  3. #3
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Coding to count number of letters (2000)

    Thats great, works a treat.
    I presume the len refers to the amount of characters?

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Coding to count number of letters (2000)

    Len() is one of several very useful string functions that determines the number of characters in a string value.
    Wendell

  5. #5
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Coding to count number of letters (2000)

    If you type "Len" in the VBEditor, put the cursor within the Word and hit F1, you can read the Help entry on the Len function.

    If you search for "Strings" in the Object Browser, the Members list of the Strings object is a large and useful collection of functions for working with strings. You can right-click on any of them and choose "Help" to find out how to use them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •