Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / April 2006

Tip: Looking for answers? Try searching our database.

Concatenating fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Reggiee - 30 Mar 2006 11:10 GMT
Hi,

I need to concatenate 3 fields where all the fields are number format.

The problem is this - when concatenating them I lose any leading 0's that
may exist in the original tables even thought ive formatted them as for
example 000 to make access put in the leading 0's.

How can I write some SQL which makes the answer more like 001-01-100 rather
than 1-1-100.

Hope this makes sense

Thanks

Reggiee
John Spencer - 30 Mar 2006 13:39 GMT
Numbers are stored without leading zeroes (or trialing zeroes).  To do what
you want you are going to have to use the Format function

For your particular example.1-1-100 to 001-01-100, try

Format([Field1],"000\-") & Format([Field2],"00\-") & Format([Field3],"000")

I include the dash (-) in the formatting, but you can simply concatenate
that in as a separate item.
Format([Field1],"000") & "-" & Format([Field2],"00")  & "-" &
Format([Field3],"000")

> Hi,
>
[quoted text clipped - 13 lines]
>
> Reggiee
Graham R Seach - 30 Mar 2006 13:47 GMT
Reggie,

Format(Field1, "000-") & Format(Field1, "00-") & Format(Field1, "000")

Regards,
Graham R Seach
Microsoft Access MVP
Canberra, Australia
---------------------------

> Hi,
>
[quoted text clipped - 13 lines]
>
> Reggiee
Reggiee - 03 Apr 2006 08:53 GMT
Thanks both

Easy when you know how eh ??

Reggiee

> Reggie,
>
[quoted text clipped - 23 lines]
> >
> > Reggiee
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.