Max Wanadoo
max.wanadoo at gmail.com
Sun Jul 5 07:18:56 CDT 2009
Arthur: Yes, that was well thought through and certainly looks ok - not something I can test from here. I suppose if you knew that all your formulaes were definitely in the "2 decimal places" or in this case "2 comma places" then you could probably just do: X = replace(x,".",",") X = left(x, instrrev(x,",")-1) & "." & mid(x,instrrev(x,",")+1) But I like you solution better. Max -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: 05 July 2009 10:55 To: Access Developers discussion and problem solving Subject: Re: [AccessD] Calculate Quartile It's a teeny bit more complicated than that, Max, but you set me to thinking. Here is my little test program and two functions, the first of which does it call by call and the second does it all in one line, using nested calls. <vba> Option Compare Database Option Explicit Sub Test() Dim x As String, y As String, z As String x = "123.456.789,12" Debug.Print x y = SwapComma(x) Debug.Print y z = SwapComma2(x) 'do it all in one call Debug.Print z End Sub Function SwapComma(x As String) x = Replace(x, ",", "%") Debug.Print x x = Replace(x, ".", ",") Debug.Print x x = Replace(x, "%", ".") Debug.Print x SwapComma = x End Function Function SwapComma2(x As String) ' not for the faint at heart SwapComma2 = Replace(Replace(Replace(x, ",", "%"), ".", ","), "%", ".") End Function </vba> Which solves the problem as posed, but makes no attempt to understand the wisdom behind Microsoft's lack of a universal representation. hth, Arthur -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com