By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Joining 2 tables in a query

P: 22
Hi, I am new to access so this may seem simple.

I am joining 2 columns of data into 1 column in a query. My expression looks like the following.

Field: ([column1] & ":" & [column2])

the Query column looks correct if there is data in both columns.

column1:column2

But when there is no data in column1 it looks like the following

:column2

How do I remove the : if there is no data in column1 so it looks like

column2
May 16 '07 #1
Share this Question
Share on Google+
4 Replies


P: 22
Ok, I figured it out. I'll post it if someone else needs.

Field: IIf([Column1]<>"",([Column1] & ":" & [Column2]),([Column1] & [Column2]))
May 16 '07 #2

P: 22
Correction from my earlier reply. This does the same result but with less expression.

Field: IIf([Column1]<>"",([Column1] & ":" & [Column2]),([Column2]))
May 16 '07 #3

100+
P: 116
You could try using a Switch function to test if there is data in column1. It looks like this:

Field: (Switch(Test1,[Column2],999,[Column1] & ":" & [Column2]))

It works like an IF statement Test1 is your test and if its true it returns expression2. Otherwise it returns your original expression(the 999 acts like a else).

Eric
May 16 '07 #4

100+
P: 116
That works too
May 16 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.