Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format cell in MSHFlexGrid?? 2

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I have tried to format my MSHFlexGrid(flexDA)columns with the following code and it will not work. Does anyone know the proper way or tell me what I'm doing wrong??

Private Sub Form_Load()
With flexDA
.TextMatrix(0, 0) = "Part Number"
.TextMatrix(0, 1) = "Part Name"
.TextMatrix(0, 2) = "Hours"
.TextMatrix(0, 3) = "Part Price"
.TextMatrix(0, 4) = "Total"
.ColWidth(0) = 1200
.ColWidth(1) = 2500
.ColWidth(2) = 750
.ColWidth(3) = 1000
.ColWidth(4) = 1000
For i = 0 to .Rows - 1
.Col = 2
.Text = Format(.Text, "#,###.0")
.Col = 3
.Text = Format(.Text, "##,###,###.00")
Next i
End With Every day above ground is a GOOD DAY!!!
 
When your doing the for - next loop, you're setting the col but not the row.

For i = 0 to .Rows - 1
.Col = 2
.row = i
.Text = Format(.Text, "#,###.0")
.Col = 3
.row = i
.Text = Format(.Text, "##,###,###.00")
Next i

You can make it run faster like this:
for i = 0 to .rows -1
.textmatrix(i,2) = Format(.Textmatrix(i,2), "#,###.0")
.textmatrix(i,3) = Format(.Textmatrix(i,3), "##,###,###.00")
next i

Herman
 
Tried it both ways and could not get it to work. I must be putting it on the wrong place. I have it in the form load event. Should it be somewhere else?
Thx. Every day above ground is a GOOD DAY!!!
 
I formatted the columns in the .AddItem Statement (on another form) before I added it to the grid and it worked ok e.g.

.AddItem New

New = rs.Fields("Part#").Value & vbTab & rs.Fields("PartName").Value & vbTab & Format(rs.Fields("Labor").Value, "#,###.0") & vbTab & Format(rs.Fields("PartPrice").Value, "##,###,###.00")

The .AddItem Statement is on another form. Should I leave it like this or do I need to format it on the Grid itself?? Every day above ground is a GOOD DAY!!!
 
As 'they' say, what ever floats your boat. - in other words, this is very much dependent on the overall app / process as to wheather it is the "Best" way to do it, but unless there are obvious problems then any way whic works is probably O.K.

If there are Problems with your choice, USERS will let you know - and probably very quickly.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Thanks Herman and Michael. I appreicate it. Every day above ground is a GOOD DAY!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top