Hi All!
I have what appears to be a simple query, only MS Query doesn't seem to like it too much. I'm trying to query a DB2 data source. I could do it just fine in Excel 2003 but we've "downgraded" to 2010 and now simple stuff doesn't work.
The following seems to generate a syntax error. Can someone help me?
([LOCN_PHY_POST_CDE] & If(isnull([LOCN_PHY_POST_EXT]),,'-' & [LOCN_PHY_POST_EXT]) as ZIP4
I've even tried this and get a syntax error :(
[LOCN_PHY_POST_CDE] & [LOCN_PHY_POST_EXT]
Is there something funky about "&" in Ms Query 2010? Jet?
TIA!
Excel 2010 & ms query...concatenate two fields?
-
- StarLounger
- Posts: 89
- Joined: 19 Feb 2010, 16:56
- Location: San Francisco, Alameda, CA
-
- Administrator
- Posts: 78857
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Excel 2010 & ms query...concatenate two fields?
Try changing
to
This works for me with Access; I can't test with DB2.
Code: Select all
If(isnull([LOCN_PHY_POST_EXT]),,'-' & [LOCN_PHY_POST_EXT])
Code: Select all
IIf(IsNull([LOCN_PHY_POST_EXT]),'','-' & [LOCN_PHY_POST_EXT])
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 89
- Joined: 19 Feb 2010, 16:56
- Location: San Francisco, Alameda, CA
Re: Excel 2010 & ms query...concatenate two fields?
Thanks Hans, but unfortunately this has to be in Excel :(
I'd settle for being able to do this: [LOCN_PHY_POST_CDE] & [LOCN_PHY_POST_EXT]
but even something simple like this generates an error, which is why I think something changed in 2010.
I'd settle for being able to do this: [LOCN_PHY_POST_CDE] & [LOCN_PHY_POST_EXT]
but even something simple like this generates an error, which is why I think something changed in 2010.
-
- Administrator
- Posts: 78857
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Excel 2010 & ms query...concatenate two fields?
I did mean MS Query in Excel but with an Access database as record source. I cannot test with a DB2 database as record source.
What happens if you use + instead of & ?
What happens if you use + instead of & ?
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 89
- Joined: 19 Feb 2010, 16:56
- Location: San Francisco, Alameda, CA
Re: Excel 2010 & ms query...concatenate two fields?
+ generates an error too.
MS query doesn't like the [ ] either. I'm guessing this is a jet problem? grrrr.
This is the exact error: incorrect column expression: '['
It does work quite perfectly in Access.
MS query doesn't like the [ ] either. I'm guessing this is a jet problem? grrrr.
This is the exact error: incorrect column expression: '['
It does work quite perfectly in Access.
Last edited by Cecilia on 01 Aug 2012, 16:44, edited 1 time in total.
-
- Administrator
- Posts: 78857
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Excel 2010 & ms query...concatenate two fields?
Sorry, since I don't have access to a DB2 database I can't help you with this.
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 89
- Joined: 19 Feb 2010, 16:56
- Location: San Francisco, Alameda, CA
Re: Excel 2010 & ms query...concatenate two fields?
No prob, Hans, I appreciate the attempt :)
-
- Administrator
- Posts: 78857
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Excel 2010 & ms query...concatenate two fields?
What if you omit the square brackets:Cecilia wrote:This is the exact error: incorrect column expression: '['.
LOCN_PHY_POST_CDE & LOCN_PHY_POST_EXT
or
LOCN_PHY_POST_CDE + LOCN_PHY_POST_EXT
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 89
- Joined: 19 Feb 2010, 16:56
- Location: San Francisco, Alameda, CA
Re: Excel 2010 & ms query...concatenate two fields?
Neither of those options works. I'm fairly certain at this point it's some sort of driver or jet issue, I just need to figure out which one, 'cause IT doesn't believe there is a problem (as usual).
-
- 5StarLounger
- Posts: 723
- Joined: 21 Aug 2011, 21:01
- Location: The beautiful hills of Western North Carolina
Re: Excel 2010 & ms query...concatenate two fields?
This may be a stupid question (as I'm not all that familiar with MS Query), but is there a missing end paren in the "If(isnull([LOCN_PHY_POST_EXT])),, " (and so on...)?Cecilia wrote:The following seems to generate a syntax error. Can someone help me?
([LOCN_PHY_POST_CDE] & If(isnull([LOCN_PHY_POST_EXT]),,'-' & [LOCN_PHY_POST_EXT]) as ZIP4
Just a thought...?
Kim
"Hmm. What does this button do?" Said everyone before being ejected from a car, blown up, or deleting all the data from the mainframe.
-
- StarLounger
- Posts: 89
- Joined: 19 Feb 2010, 16:56
- Location: San Francisco, Alameda, CA
Re: Excel 2010 & ms query...concatenate two fields?
Hi Kim,
No such thing as a stupid question. But right now I'm just trying to get LOCN_PHY_POST_CDE & LOCN_PHY_POST_EXT to work, and it has no paren or brackets, or anything else. :-/
Thanks :)
No such thing as a stupid question. But right now I'm just trying to get LOCN_PHY_POST_CDE & LOCN_PHY_POST_EXT to work, and it has no paren or brackets, or anything else. :-/
Thanks :)