Solved

Error on nulls with Left Mid() function

Posted on 2011-03-12
7
427 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
Comment Utility
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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
"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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
@JDettman:
"Nice to see you wanting to go the extra mile here,"
Huh?  Not related.
0
 
LVL 8

Expert Comment

by:Andrew_Webster
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now