473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Difference between Left() and Left$() function

Hello All,

I am trying to debug a broken query. The query uses
Left$([blahblah],4) instead of Left([blahblah],4).

What is the difference between the Left() and Left$() functions in
Microsoft Access?

Thanks!
--
Nathan

Keywords: MS Microsoft Access Functions Function Left Left$ Left()
Left$() Query
Nov 12 '05 #1
2 35061
The trailing $ is a type declaration character for the String data type in
VBA.

The result returned from Left$() is a string, whereas Left() returns a
Variant.

You must use Left(), not Left$() if there is any chance of Null values,
since the Variant can be Null but the String cannot. To demonstrate that:
1. Press Ctrl+G to open the Immedate window.

2. Enter:
? Left(Null,1)
The answer is Null.

3. Now enter:
? Left$(Null,1)
This generates Error 94. Since the result should be Null, and the String
cannot be Null, you receive the error, "Invalid use of Null".

If you are dealing with string values, in VBA code, Left$() will be slightly
more efficient, as it avoids the overhead/inefficieny associated with the
Variant. However, if there is *any* chance that Nulls may be involved, use
Left(), or else explicitly handle the Null with something such as Nz().

More information on Nulls:
http://allenbrowne.com/casu-11.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nathan Given" <ng****@hotmail.com> wrote in message
news:f7**************************@posting.google.c om...
Hello All,

I am trying to debug a broken query. The query uses
Left$([blahblah],4) instead of Left([blahblah],4).

What is the difference between the Left() and Left$() functions in
Microsoft Access?

Thanks!
--
Nathan

Keywords: MS Microsoft Access Functions Function Left Left$ Left()
Left$() Query

Nov 12 '05 #2
left$() will return a string or generate an error if passed NULL
left() will return a string or NULL if passed NULL

"Nathan Given" <ng****@hotmail.com> wrote in message
news:f7**************************@posting.google.c om...
Hello All,

I am trying to debug a broken query. The query uses
Left$([blahblah],4) instead of Left([blahblah],4).

What is the difference between the Left() and Left$() functions in
Microsoft Access?

Thanks!
--
Nathan

Keywords: MS Microsoft Access Functions Function Left Left$ Left()
Left$() Query

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: WittyGuy | last post by:
Hi, What is the major difference between function overloading and function templates? Thanks! http://www.gotw.ca/resources/clcm.htm for info about ]
4
by: Marek Kotowski | last post by:
Hi, What is the real difference between LEFT JOIN and RIGHT JOIN? Are there situations where a query with RIGHT JOIN cannot be rewritten with LEFT JOIN and tables reversed? (and vice versa). ...
17
by: Nathan Given | last post by:
Hello All, I am trying to debug a broken query. The query uses Left$(,4) instead of Left(,4). What is the difference between the Left() and Left$() functions in Microsoft Access? Thanks!...
4
by: Agnes | last post by:
in .net , any left function ?? or I should use Microsoft.VisualBasic.Left(myString, 5) Thanks
3
by: OutdoorGuy | last post by:
Greetings, I have a "newbie" question. I was wondering if there is anything in C# that corresponds to VB's "Left" function? I simply want to retrieve the leftmost characters of a string and I...
6
by: flopbucket | last post by:
Could someone explain to me what the difference is between function template specialization and function overloading? I guess overloading can change the number of parameters, but otherwise they...
2
by: Rhishabh07 | last post by:
difference between (left, right, inner, outer) join? anybody can help me? Thanx
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.