Solved

Error on nulls with Left Mid() function

Posted on 2011-03-12
7
440 Views
Last Modified: 2012-05-11
this function in Access produces an error on nulls in the column:
Left(Right(,Len()-InStr(),"(")),Len(Right(,Len()-InStr((),"(")))-1) - how can this be rewritten so that it will convert nulls into empty strings?  

Also, will this work in SQL 2005?  thanx
0
Comment
Question by:bar0822
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 8

Accepted Solution

by:
Andrew_Webster earned 250 total points
ID: 35116239
Use Nz(MyColumn,"").

Nz will work in an Access query of linked SQL Server data.  It will not work in a pass-through query that is evaluated by SQL Server as it's a VBA method, not a SQL method.

In T-SQL you can use ISNULL(MyColumn,"") instead.
0
 
LVL 75
ID: 35117341
I hate to say this, but your expression has many issues.  For starters, your InStr() functions have no arguments ... which is your first issue.  Next, Your Right() function syntax is incorrect.  

Left(Right(,Len()-InStr(),"(")),Len(Right(,Len()-InStr((),"(")))-1)


Left(Right(,Len()-InStr(),"(")),Len(Right(,Len()-InStr((),"(")))-1)

Please look these up in VBA Help to get the correct syntax ...

mx
0
 
LVL 75
ID: 35326011
"bar0822 declined to include the actual strings and/or fields used in the expression and in doing so"
I see. Just to make it a trick question.
0
 
LVL 75
ID: 35326029
@JDettman:
"Nice to see you wanting to go the extra mile here,"
Huh?  Not related.
0
 
LVL 8

Expert Comment

by:Andrew_Webster
ID: 35328105
I agree with everyone!  Yes, the expression is a mess, and a royal pain to debug.  But the question was about how to convert Nulls to empty strings, and that was the answer given.

If I was stuck with that expression, I'd probably write a VBA function to clean it up, and call that from a query.  But even that might depend on the performance, as if it's in a query that hits many rows then performance could be a dog.

But I'm not going to go into "what ifs" or I'd drive myself nuts.  More nuts.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question