Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging 2 fields in a Append Query

Status
Not open for further replies.

rjurgens

MIS
Jul 9, 2003
37
GB
I have a query that Appends selected data into the main table. I want to create a key ID field where I merge 2 fields into 1 in order to make a unique number. Any help would be much appreciated.
 
Hi rjurgens,

It depends a little on whether your fields are numbers or text, and exactly how you want to combine them. to simply concatenate them use ..

[blue][tt][ID1]&[ID2][/tt][/blue]

If they are numbers and you want the concatenated result to be a number, you could use ..

[blue][tt]Val([ID1]&[ID2])[/tt][/blue]

But you might have to consider what to do if the numbers are different lengths:

101 & 9 would give 1019
10 & 19 woud also give 1019

In this example, you might want to do ..

[blue][tt]Val([ID1]&Format([ID2],"00"))[/tt][/blue]

.. or ..

[blue][tt][ID1]*100+[ID2][/tt][/blue]

.. for example, to return 10109 from 101 and 9

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Thanks Tony. For some reason when I did it the first time, it did not work. Must have mistyped, but it works now. Thanks for taking the time to reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top