469,294 Members | 1,571 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,294 developers. It's quick & easy.

How to GIve Format to the data in mshflexgrid?

dnb
34
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.
Jan 3 '08 #1
6 2755
debasisdas
8,127 Expert 4TB
that can be done directly by using sql statment

try like this

select id,name, '$.' ||salary as sal from employee
Jan 3 '08 #2
Killer42
8,435 Expert 8TB
Yes, but shouldn't Format function also work in SQL?
Jan 4 '08 #3
debasisdas
8,127 Expert 4TB
Yes, but shouldn't Format function also work in SQL?
Yes ,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.
Jan 4 '08 #4
QVeen72
1,445 Expert 1GB
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 :
Expand|Select|Wrap|Line Numbers
  1. Grd.TextMatrix(i, 2) = Format(RS("MyAmt"), "$#.##")
  2.  
If using First method, then
After Binding to the datasource, Just loop through all the Rows and Format:
Expand|Select|Wrap|Line Numbers
  1. Dim i As Long
  2. For i = 1 To Grd.Rows-1
  3.   Grd.TextMatrix(i, 2) = Format(Val(Grd.TextMatrix(i ,2)) ,"$#.##")
  4. Next
  5.  
Regards
Veena
Jan 4 '08 #5
Killer42
8,435 Expert 8TB
Yes ,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.
No, I mean can't you include Format() function in SQL? I thought Access SQL at least, had a Format function for just this kind of situation.

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
028000
Jan 4 '08 #6
QVeen72
1,445 Expert 1GB
Hi,

For Access Database, Directly Change the SQL Statement:

"Select Field1,Format(AmtField,'##,###.00') As MyAmtField From MyTable"

Regards
Veena
Jan 4 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by doller | last post: by
4 posts views Thread by giddy | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.