Results 1 to 11 of 11
  1. #1
    Join Date
    May 2003
    Location
    Dallas
    Posts
    779

    left() function giving wrong number of arguments error

    Hey guys

    I am using the left function in a procedure. the snippett is

    If Left(ctl.name, 3) = "lst" Then

    blah blah blah
    end if

    I have never had problems with any string functions before but lately in Access '97 I have been getting "wrong number of arguments" errors when trying to implement the left function.
    The above syntax is correct and exact code runs in 2000, 2003, 2007

    In fact the right function in my 97 is working perfectly.

    Here is the kicker - Any existing left functions I had in the app ssay about a week or so earlier work fine - it is only when I am trying to add new left functions that this occurrs.
    Dale Houston, TX

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,115
    backup the database, perform a compact and repair.

    Check references.


    errr....
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    12,532
    Access 2007 may be a bot more sniffy, and require the precise property. older VB & VBA has a default property, .NET abolished such a concept, so its possible that newer versions are going down that avenue. generally I suspect its a smart idea NOT to rely on default properties, and always explicitly refer to the precise property you want to access.

    so it may be
    Code:
    If Left(ctl.name.text, 3) = "lst" Then
    or .value

    but whethjer that is the root cause of the problems here I dunno
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580

    Lightbulb ctl.name.text

    Make sure this is at least 3 characters long also else you may get an error if its shorter or null.

    if len(ctl.name.text>=3) then

    If Left(ctl.name.text, 3) = "lst" Then

    your code here

    end if

    end if
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  5. #5
    Join Date
    May 2003
    Location
    Dallas
    Posts
    779
    without a doubt the number of characters is 3 - as I said it works fine in other versions - just stopped in 97 - no matter what app am I am in - the weird thing is that the right function still works fine
    Dale Houston, TX

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    12,532
    Is there a differnece if you try LEFT$......
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    May 2003
    Location
    Dallas
    Posts
    779
    no difference
    this sucks
    Dale Houston, TX

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,115
    I think the easiest way to prove the function is screwy would be something like this
    Code:
    MsgBox Left("test", 3)
    If you're happy it's screwed, then try my suggestions from post #2.
    George
    Home | Blog

  9. #9
    Join Date
    May 2003
    Location
    Dallas
    Posts
    779
    I did the debug.print the same way and it did give me the 'tes'

    but the left funtion for the ctl.name is failing in any new procedures yet it is functioning in other modules where I had put it before - in addition the right funtion using ctl.name works fine

    I have compacted and repaired this app literally 7 times in the last day and a half

    sounds like I need to put everything in a new container

    and no geo - i am not happy with the 'being screwed'
    Dale Houston, TX

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,115
    Let's back-up a minute...

    What happens if you Debug.Print ctl.name ?

    Also, can you post the full code, i.e. I want to know how ctl is assigned.
    George
    Home | Blog

  11. #11
    Join Date
    May 2003
    Location
    Dallas
    Posts
    779
    in an existing module and one I can recreate this works fine

    If left(Right(mysum, 2), 1) = "." Then
    mysum = CStr(mysum) & "0"
    End If

    but if I try left(mysum,1) I get the error

    weird
    I agree - sounds like corruption
    Dale Houston, TX

Posting Permissions

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