If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > left() function giving wrong number of arguments error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Grand Poobah
 
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
Reply With Quote
  #2 (permalink)  
Old
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 11,002
backup the database, perform a compact and repair.

Check references.


errr....
__________________
George
Home | Blog
Reply With Quote
  #3 (permalink)  
Old
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 12,090
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #5 (permalink)  
Old
Grand Poobah
 
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
Reply With Quote
  #6 (permalink)  
Old
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 12,090
Is there a differnece if you try LEFT$......
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #7 (permalink)  
Old
Grand Poobah
 
Join Date: May 2003
Location: Dallas
Posts: 779
no difference
this sucks
__________________
Dale Houston, TX
Reply With Quote
  #8 (permalink)  
Old
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 11,002
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
Reply With Quote
  #9 (permalink)  
Old
Grand Poobah
 
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
Reply With Quote
  #10 (permalink)  
Old
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 11,002
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
Reply With Quote
  #11 (permalink)  
Old
Grand Poobah
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On