How to give format of data - " which are picked up from Access database through query" - in mshflexgrid in vb 6.0? I want to give currency format to the data. I used Format function in query but it does not work. So please give any idea for this. Thanks in advance.
How to GIve Format to the data in mshflexgrid?
Collapse
X
-
that can be done directly by using sql statment
try like this
select id,name, '$.' ||salary as sal from employee -
Originally posted by Killer42Yes, but shouldn't Format function also work in SQL?Comment
-
Hi,
How you are populating the MSHFlexGrid..? Setting DataSource or Open Recordset and Loop Through and add row by row..?
If using second method then, you can populate the textmatrix with the formatted String :
[code=vb]
Grd.TextMatrix( i, 2) = Format(RS("MyAm t"), "$#.##")
[/code]
If using First method, then
After Binding to the datasource, Just loop through all the Rows and Format:
[code=vb]
Dim i As Long
For i = 1 To Grd.Rows-1
Grd.TextMatrix( i, 2) = Format(Val(Grd. TextMatrix(i ,2)) ,"$#.##")
Next
[/code]
Regards
VeenaComment
-
Originally posted by debasisdasYes ,but you need to format the string before passing to SQL and processing or first fetch from sql and then format as per your requirment.
Ok, I've just checked. Here's some SQL which I built in the Access Query Designer. It works, displaying the numeric field aaa as six digits.
SELECT Format([aaa],"000000") AS Um FROM Table1;I entered the values 1, 2, 3 and 28000 in field aaa, then ran this query. Here's the output...
Um
000001
000002
000003
028000Comment
Comment