Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Concatenate in Query with Leading Zero

Posted on 2010-01-12
3
Medium Priority
?
490 Views
Last Modified: 2013-11-28
Happy New Year!

I have a Acces query to Concatenate two number fields and I keep loosing the leading zeros. heres what I have;

Field1             Field2
MaxYr         MaxNum

Value in Field 1..
10
Value in Field 2..
001

..I would like the desired concatenated result to be..
10-001
..but I keep getting..
10-1    (I keep loosing the leading zeros)

Here is my code in the query;
CONTMAX: "M" & [MaxYr] & "-" & [MaxNum]

Can anyone please help me figure this out!?  Thanks a very bunch!

Naeem~
0
Comment
Question by:naeemahmad
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1500 total points
ID: 26300265
Try this:

CONTMAX: "M" & Format([MaxYr],"00") & "-" & Format([MaxNum],"000")

mx
0
 

Author Closing Comment

by:naeemahmad
ID: 31676485
That worked perfectly!

Thanks as always and Happy coding in 2010!
0
 
LVL 75
ID: 26300524
"That worked perfectly!"
You are welcome.

mx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question