473,395 Members | 1,869 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,395 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 35072
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.