Connecting Tech Pros Worldwide Help | Site Map

Update query to certain number format

Member
 
Join Date: Sep 2006
Posts: 76
#1: 2 Weeks Ago
I'm trying to figure out how to get an update query to work. I need to get dollar amounts into standard lengths and formats for export into our main system. The dollar amounts need to be 17 digits with zero's to the left and no decimal. For example:

$7.26 becomes 00000000000000726
$24,974.57 becomes 00000000002497457

and so on.

Can anyone help with what formula to put into the Update To: section of the query???
best answer - posted by ADezii
Quote:

Originally Posted by ckpoll2 View Post

I'm trying to figure out how to get an update query to work. I need to get dollar amounts into standard lengths and formats for export into our main system. The dollar amounts need to be 17 digits with zero's to the left and no decimal. For example:

$7.26 becomes 00000000000000726
$24,974.57 becomes 00000000002497457

and so on.

Can anyone help with what formula to put into the Update To: section of the query???

With a Currency Field, you may be better off displaying your results in a Calculated Field. Assuming your Table name is tblProject, and your Currency Field is [Amount], to Format the results in a Calculated Field named [Converted_Amount] to 17 digits with leading zeros, no Decimals, and the 2 rightmost digits representing cents:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblProject.Amount, Format(100*[Amount],"00000000000000000") AS Converted_Amount
  2. FROM tblProject
  3. WHERE (((tblProject.Amount) Is Not Null));
Sample OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Amount            Converted_Amount
  2. $7.26             00000000000000726
  3. $24,974.57        00000000002497457
  4. $85.00            00000000000008500
  5. $1.03             00000000000000103
  6.  
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,213
#2: 2 Weeks Ago

re: Update query to certain number format


Quote:

Originally Posted by ckpoll2 View Post

I'm trying to figure out how to get an update query to work. I need to get dollar amounts into standard lengths and formats for export into our main system. The dollar amounts need to be 17 digits with zero's to the left and no decimal. For example:

$7.26 becomes 00000000000000726
$24,974.57 becomes 00000000002497457

and so on.

Can anyone help with what formula to put into the Update To: section of the query???

With a Currency Field, you may be better off displaying your results in a Calculated Field. Assuming your Table name is tblProject, and your Currency Field is [Amount], to Format the results in a Calculated Field named [Converted_Amount] to 17 digits with leading zeros, no Decimals, and the 2 rightmost digits representing cents:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblProject.Amount, Format(100*[Amount],"00000000000000000") AS Converted_Amount
  2. FROM tblProject
  3. WHERE (((tblProject.Amount) Is Not Null));
Sample OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Amount            Converted_Amount
  2. $7.26             00000000000000726
  3. $24,974.57        00000000002497457
  4. $85.00            00000000000008500
  5. $1.03             00000000000000103
  6.  
Member
 
Join Date: Sep 2006
Posts: 76
#3: 2 Weeks Ago

re: Update query to certain number format


You are amazing!! Thanks so much for your help!!
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#4: 2 Weeks Ago

re: Update query to certain number format


Very much along the lines ADezii has already suggested :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Amount],
  2.        Format(100*[Amount],String(17,'0')) AS Converted_Amount
  3. FROM   tblProject
  4. WHERE  ([Amount] Is Not Null)
Member
 
Join Date: Sep 2006
Posts: 76
#5: 2 Weeks Ago

re: Update query to certain number format


You guys are great. Thanks again!!
Reply


Similar Microsoft Access / VBA bytes