Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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
 
Old July 5th, 2007, 01:52 AM
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sathija
Default 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
 
Old July 5th, 2007, 03:35 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

 
Old July 6th, 2007, 06:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
 
Old July 6th, 2007, 07:00 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

 
Old July 6th, 2007, 07:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
 
Old July 6th, 2007, 07:25 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
If field not present then add spaces and concat pixelheart XSLT 14 June 5th, 2008 02:13 AM
Determine next autonumber field value U.N.C.L.E. SQL Server ASP 2 February 22nd, 2007 04:01 AM
AutoNumber field tulincim Access 5 June 6th, 2006 03:44 PM
Hiding Autonumber Field Brendan Bartley Access 4 November 14th, 2005 11:34 AM
Deriving an Autonumber field paulkholt Pro VB Databases 0 August 20th, 2004 10:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.