473,418 Members | 2,233 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,418 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 35075
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.