[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How remove decimal and 2 trailing zeros from multiple values in field

Posted on 2006-07-13
15
Medium Priority
?
1,034 Views
Last Modified: 2008-03-06
Hello,

I have a table that has numeric values (eg. 2506.00) that I have already convert to text.  Now I need to remove the decimal and the 2 trailing zeros.  The field name is Group_Index.  Also, in case you need to know, the values are not all 4 digits. They actually start at 1.00, then go all the way to 2506.00.

So I want 2506.00 to be changed to 2506.

Would I do this using an update query?  How should it be written?  If you can provide me with the SQL that would be even better!

Thanks!
0
Comment
Question by:pelampe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
15 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17099853
u could try round

round(2506.00,0)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17099863
or format

format(2506.00,"0")
0
 
LVL 44

Expert Comment

by:GRayL
ID: 17099874
update mytable set myfld = replace(myfld,".00","");
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 65

Expert Comment

by:rockiroads
ID: 17099978
yes, update query, thats what u asked for in your last sentence!
Well I guess GRayL has given u the syntax
and after re-reading, values are not all digits

stick with his solution

0
 

Author Comment

by:pelampe
ID: 17100219
Couldn't get it to work.

Here is the SQL:

UPDATE Parcel_Info SET Parcel_Info.Group_Index = replace(Group_Index,".00","");

Here is the error message: Undefined function 'replace' in expression

Let me know what I'm doing wrong, please.

BTW, using Access 97 is that is relevant.

Phil.
0
 
LVL 4

Expert Comment

by:Carl2002
ID: 17100579
If its text you could use instr() to locate the decimal point then take everything to the left of it.

heres the syntax

Expr1: IIf(InStr([field1],".")=0,[field1],Left([field1],InStr([field1],".")))

Just an idea.

Carl.
0
 

Author Comment

by:pelampe
ID: 17102213
Carl,

Almost worked.  Took the 2 trailing zeros off.  But left the decimal.

So it went from this: 2506.00

to this 2506.

Any ideas?
0
 
LVL 38

Accepted Solution

by:
Jim P. earned 100 total points
ID: 17103228
How about

UPDATE Parcel_Info SET Parcel_Info.Group_Index = Left(Group_Index,Len(Group_Index)-3   );
0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 100 total points
ID: 17112332
Replace does not work with Jet In A97.  You could also try:

UPDATE Parcel_Inof SET Parcel_info.Group_Index = Left(Group_Index,Instr(Group_Index,".00")-1)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17113714
Ray, here is a version of Replace for A97

Public Function A97Replace(pstrIn, pstrOld, pstrNew)

    Dim strWork As String
    Dim strL As String
    Dim strR As String
    Dim intX As Integer
    strWork = pstrIn
   
    Do
        intX = Nz((InStr(1, strWork, pstrOld, vbTextCompare)), 0)
        If intX > 0 Then
            strL = Left$(strWork, intX - 1)
            strR = Right$(strWork, (Len(strWork) - intX - Len(pstrOld) + 1))
            strWork = strL & pstrNew & strR
        Else
            Exit Do 'Escape from the loop if nothing else to do
        End If
    Loop
   
    A97Replace = strWork
End Function


so u could still use your original solution

update mytable set myfld = a97replace(myfld,".00","");


UPDATE Parcel_Info SET Parcel_Info.Group_Index = A97Replace(Group_Index,".00","");



But Jim's and your alternative solution will work just as well so as long as it just ends with .00



0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17113716
By the way, the post if for information only, not an attempt to get points! so please do not accept my post as part of any solution
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 17445398
No objecions
0
 

Author Comment

by:pelampe
ID: 17504022
Hello All,

I apologize for not responding sooner, but I just got back from a two week vacation, yesterday.

BTW, you all have been a TREMENDOUS help to me in getting a better grip on how to use Access  and I GREATLY apprieciate having a forum like this!

Please accept my humble apology.

Have a great day!

Phil
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

656 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