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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to set different editmasks for different rows in the same column. 1

Status
Not open for further replies.

pbp

Programmer
Jul 25, 2002
8
US
Hello,

Somebody help, please.

The problem:

I have a column in the dw(the db value is numeric [15,6]).

The column needs to have different edit and display characteristic for different rows.
For rows #1-#22 it is greyed out, not editable (format #,###.00).
For the row #23 - editable, editmask and format = #,###.00
For the row #24 - editable, editmask and format = #,###.000000
For the row #25 - it is greyed out, not editable (format #,###.00).
For the row #26 - editable, editmask and format = #,###.00
For the row #27 - editable, editmask and format = #,###.000000
and so on....

I was able to make it behave the way expected, except one thing.
I CAN NOT FIND A WAY TO SET DIFFERENT EDITMASKS FOR DIFFERENT ROWS. IT WORKS ONLY FOR THE WHOLE COLUMN.

I tried putting code in the editchanged event, it did not work.

If someone had a similar problem - please let me know your solution.


Thank you so much,

pbp.
 
Hi,

Could u give the details of which rows do u want to set 2 decimals and 6 decimals... i mean if it is in multiples or a range??

Depending on that u can modify the settings at the design level of the datawindow itself using the IF condition.

Give me the details .. say now that u say row 24 is 2 dec and row 27 is 6 dec

so as per that will row 30 have 6 dec again?? and in b/w 2 de???
 
Hi bubbly,

Thank you for reply.

I have a predefined range of rows. Only #24 and #27 have to have 6 dec., all other rows will have only 2 dec.

I tried to set editmask thru dot notation in ItemChanged event ( and even in EditChanged), but it sets the editmask for the whole column.

I hope it clarifies more what I am trying to do.

Thanks,

pbp
 
PBP,

Are these rows going to be inserted or retrieved onto the datawindow? If they are going to be inserted, I would place your code in either the insert or pre_insert event to set the edit mask for the column.

If they are going to be retrieved onto the datawindow, then place your code in the retrieveend event. You could also look at putting code in the rowfocuschanged event to set the edit mask for your column as the user scrolls through the rows on the datawindow.

HTH
Daniel
 
Thank you, Daniel32,

This column is retrieved from db and is editable by the user.
At the retrieve time I can set format and get rid of extra 0000. But as the user enters the value he/she wants to see only .00. At the retrieveend event I put a code:


for i = 1 to ll_rows

if this.GetItemNumber(i, "expense_item_expense_code") = 24 or &
this.GetItemNumber(i, "expense_item_expense_code") = 27 then

dw_expense.Object.expense_item_annual_expns_amt.EditMask.Mask = "###,###.000000"
dw_expense.Object.expense_item_annual_expns_amt.Format = "###,###.000000"

else
dw_expense.Object.expense_item_annual_expns_amt.EditMask.Mask = "###,###.00"
dw_expense.Object.expense_item_annual_expns_amt.Format ="###,###.00"

end if
Next


Expense_item_expense_code, lets say,is numbered as rows.
This code sets the whole column to either one of the editmasks, whichever is last.
Do you know of any other way to set it in code?

Thanks,

pbp
 
Hi Pbp,

I guess i have got a solution for ur problem. It seems to be very simple.

In the Datawindow Design painter select the column properties i.e, Numeric(15,6) and click on the Format tab.

Modify the expression as follows:

case( getrow() when 24 then "#,###.000000" when 27 then "#,###.000000" else "#,###.00")

I am sure this should work.
The format doesn't change even while the user edits the column.

Check it out and let me know
 
Pbp,

I would use the method that bubbly suggested. That looks like it would work quite well.

Daniel
 
Thanks Bubbly and Daniel,

I tried that before too. Format is working fine. BUT at the time when the user puts the cursor or tabs into that field, it shows #,###.000000.

I came around that problem by creating a dummy editable column and putting it on top of THE column(expense_item_annual_expns_amt), visible property will change based on the row. I set the needed editmask on the dummy column and interchange data between two columns at the Retrieveend and Itemchanged events ( since it is involved in various calculations).

That seems to work.

FYI
By the way,
I think I found a bug in PB:
When you set editmask to ###.00, you can still type in unlimited amout of decimals if you start keying in from ".", without the integer part of the number.

Well, thank you for support and advices.

Eugenia.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top