ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   formatting results from mysql query (https://www.excelbanter.com/excel-programming/281576-formatting-results-mysql-query.html)

Michael J. Malinsky

formatting results from mysql query
 
I have a function that grabs a number from a mysql database. To return the
number, I use:

GetMySql = myrs.Fields(lString).Value

and the result in the spreadsheet is returned as, for example, 3980 and is
left justified as if it were a string.

If I try

GetMySql = Format(myrs.Fields(lString).Value, "#,##0")

the result is 3,980 and is still left justified.

then i tried

GetMySql = CCur(myrs.Fields(lString).Value)

and now it's right justified, but it shows as 3980.

So how can I get the number returned as a number type format with a comma
and make it right justified?

Seems simple, but I'm beating my head against the keyboard.

TIA
Mike


--
Michael J. Malinsky




Dick Kusleika[_3_]

formatting results from mysql query
 
Mike

Can you use CCur (or CDbl) and format the cell for the number format you
want? That seems like the way to go, but let me know if there's a problem
with that. I don't think you can do it solely within the function.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Michael J. Malinsky" wrote in message
...
I have a function that grabs a number from a mysql database. To return

the
number, I use:

GetMySql = myrs.Fields(lString).Value

and the result in the spreadsheet is returned as, for example, 3980 and is
left justified as if it were a string.

If I try

GetMySql = Format(myrs.Fields(lString).Value, "#,##0")

the result is 3,980 and is still left justified.

then i tried

GetMySql = CCur(myrs.Fields(lString).Value)

and now it's right justified, but it shows as 3980.

So how can I get the number returned as a number type format with a comma
and make it right justified?

Seems simple, but I'm beating my head against the keyboard.

TIA
Mike


--
Michael J. Malinsky






Michael J. Malinsky

formatting results from mysql query
 
Dick,

I ended up using CDbl and then formatting the cell. If I get this working,
the cell will protected so formatting shouldn't be an issue.

Thanks.
Mike

--
Michael J. Malinsky


"Dick Kusleika" wrote in message
...
Mike

Can you use CCur (or CDbl) and format the cell for the number format you
want? That seems like the way to go, but let me know if there's a problem
with that. I don't think you can do it solely within the function.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Michael J. Malinsky" wrote in message
...
I have a function that grabs a number from a mysql database. To return

the
number, I use:

GetMySql = myrs.Fields(lString).Value

and the result in the spreadsheet is returned as, for example, 3980 and

is
left justified as if it were a string.

If I try

GetMySql = Format(myrs.Fields(lString).Value, "#,##0")

the result is 3,980 and is still left justified.

then i tried

GetMySql = CCur(myrs.Fields(lString).Value)

and now it's right justified, but it shows as 3980.

So how can I get the number returned as a number type format with a

comma
and make it right justified?

Seems simple, but I'm beating my head against the keyboard.

TIA
Mike


--
Michael J. Malinsky









All times are GMT +1. The time now is 04:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com