Solved

Error on nulls with Left Mid() function

Posted on 2011-03-12
7
438 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
  • 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sum in Split Form 17 28
SQL trigger 5 22
Problem with vba code 4 39
How search for records based on a specified date range 14 17
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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 …

861 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