By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

How to GIve Format to the data in mshflexgrid?

dnb
P: 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
Share this Question
Share on Google+
6 Replies


debasisdas
Expert 5K+
P: 8,127
that can be done directly by using sql statment

try like this

select id,name, '$.' ||salary as sal from employee
Jan 3 '08 #2

Expert 5K+
P: 8,434
Yes, but shouldn't Format function also work in SQL?
Jan 4 '08 #3

debasisdas
Expert 5K+
P: 8,127
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
Expert 100+
P: 1,445
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

Expert 5K+
P: 8,434
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
Expert 100+
P: 1,445
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.