 |
| Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 5th, 2007, 01:52 AM
|
|
Registered User
|
|
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Concat autonumber field with a constant character
I need to concat an autonumber field with a specific constant value say ABC and it has to be populated as another field in the same table. Can somebody help me out in this
Thanks in Advance :)
sathishkumar J
|
|

July 5th, 2007, 03:35 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Are you working in a Form or in ADO/DAO code??
If a Form, just add a control linked to the field you would like to set and then set its value to the desired value, e.g:
TargetTxt.Value = ID.Value & A_CONST
If in Code, then it would be something like:
rs("TargetField").Value = rs("ID") & A_CONST
I hope this points you in the right direction.
Regards,
Rob
|
|

July 6th, 2007, 06:50 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Actually, you wouldn't concatentate it at all. You would set up a field for JUST the text part of the combined number and store it. You never store concatenated or calculated fields. It bloats your dB size. Store ONLY the two halves and then combine them on the fly in reports and forms.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

July 6th, 2007, 07:00 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Would JOINS still be possible using your method though Greg? I have never seen anything like that in use, just curious, would be interesting to know?
Regards,
Rob
|
|

July 6th, 2007, 07:19 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Joins? I'm not sure to what you're referring. Store the autonumber part, say lngRecNo. Store the text part, say strCode. Then later combine them in a report, say strCustID = CStr(lngRecNo) & strCode.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

July 6th, 2007, 07:25 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Just had a thought, never mind, if you need to use joins (linking given table to another) you could of course just join both the fields and let them both act as FK's...
Sorry, having a funny five mins! got my head right into my project at work!
Regards,
Rob
|
|
 |