Set a base formatted field value by macro

image description
I

Please, how do I set a value in a formatted field, formatted as currency. It is not tied into a DB field. Have tried .CurrentValue= and .SelectedValue=. One was not recognised and the other was read only error.
formContainer=ThisDataBaseDocument.FormDocuments.getByName(“Master Maintenance”)
formContainer.open
’ wait 500
mainForm=formContainer.Component.getDrawPage().getForms().getByIndex(0)
control=mainForm.getByName(“fmtAllBanks”)
control.CurrentValue=SumAllGifters

Thankyou any help would be appreciated.

Answered below.

1 Like

Maybe use an SQL Update statement, search for update and check out the doco for your database

as I mentioned the field is not tied to a DB. It is being calculated and placed in the field for display.

I don’t know if this will help or not. I would use xray tool to try to make absolutely sure the object I am trying to set is correct. Be careful of structures that look like strings. Try your procedure on a field without formatting to see if you are close to the answer.

If that doesn’t help, maybe search the open office forum. There is a lot of macro discussion there.

-hink

I found an answer with a bit of trial and error.

control=mainForm.getByName("fmtAllBanks")
control.EffectiveValue=var

Find the control then use EffectiveValue. I don’t know if it’s the correct way but it works.
To get the value use CurrentValue.

control=mainForm.getByName("fmtBank")
Ba=control.CurrentValue

I hope this helps.

This worked for me, after a fashion, when using a datagrid, changing the value of a column A when the value of another column B is changed. Column A can be in fact at times a calculated column (when the user changes B), but it is also a column in the underlying table.

But the reason I mention it is because I found that although the value had changed, this could be ascertained only by tabbing to the column in question on the datagrid row, and then pressing Return: the new value would then be displayed.

But I found the key to displaying the new value immediately:

# where '8888' is the new value to which you want to set this column in the current row
charge_col.EffectiveValue = '8888'
charge_col.commit()

NB commit() here has, seemingly, nothing to do with a database commit: after this command the icon at the left of the datarow still remains “edit”, and you have to validate (e.g. F9) to get the new data to be committed to the table in the database source.