Ask Your Question
0

SAVE isn't saving the updated field (Macro Issue)

asked 2020-03-03 06:33:40 +0200

MQ-818 gravatar image

updated 2020-03-03 06:40:27 +0200

Ratslinger gravatar image

So here is the Macro....That is working!!! But fail to SAVE

After running the following macro, I can see the correct % at the form (MsgBox & Field). The field that is receiving the data back is "txtCal_DownPay_P" only part that is missing is even though the information is updated form's SAVE button still gray and I can't save it. The only way to save it is....If I go to that field and rewrite the calculated info than SAVE wakes up!! How to fix it, please!!!

Sub Call_Calculator (Event as Object)
        dim Form as Object
        dim tempP_SalesPrice as double  
        dim tempDownPay as double
        dim tempDownPay_P as double

        Form = Event.Source.Model.Parent

        tempP_SalesPrice = Form.getByName("txtP_SalesPrice").currentvalue

        tempDownPay = Form.getByName("txtCal_DownPay").currentvalue

        tempDownPay_P = tempDownPay / tempP_SalesPrice

        Form.getByName("txtCal_DownPay_P").text = tempDownPay_P

        MsgBox("Down payment % is "& tempDownPay_P)

End Sub
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2020-03-03 06:50:11 +0200

Ratslinger gravatar image

updated 2020-03-03 21:36:11 +0200

Hello,

Haven't time to test currently but if needed will do so after a good night's sleep.

You move the data into the control but that is all. You need to commit() it.

Try this. Change this line:

Form.getByName("txtCal_DownPay_P").text = tempDownPay_P

to:

Dim oField as Object
oField = Form.getByName("txtCal_DownPay_P")
oField.text =  tempDownPay_P
oField.commit()

Fairly certain that's the code. Also not sure why you are using a text box and text instead of a numeric control and setting via .value?

Edit 2020-03-03:

Please, always include OS, specific LO version and database used (seems this is a split HSQLDB but not certain of version). Should not need to trace through old questions and things can change rapidly.

Don't know what problem you are having. Used your code (changed control names to what I have) and used my modification from above. Worked first time!

Note that in the sample I have removed the enabled property for the control since it is a calculation.

Sample ------ FieldCalc.odb

edit flag offensive delete link more

Comments

Hi Ratslinger: I just tried your suggestion and It didn't solve the issue. It did produce the same result as I had before. Correct updated answer at the form's field but failed to save.

MQ-818 gravatar imageMQ-818 ( 2020-03-03 20:28:59 +0200 )edit

@MQ-818,

Please see edited answer

Note: field is calculated when you exit the DownPay field.

Ratslinger gravatar imageRatslinger ( 2020-03-03 21:37:38 +0200 )edit

Ratslinger:

FieldCalc.odb Works .....Thanks for your kind help.

Monjur

MQ-818 gravatar imageMQ-818 ( 2020-03-03 22:31:05 +0200 )edit
0

answered 2020-03-03 22:25:47 +0200

MQ-818 gravatar image

Added the following line and all started to work.

oForm.Columns.GetByName( "Cal_DownPay_P" ).updatedouble(tempDownPay_P,3)

here Cal_DownPay_P is the Field Name in the Table And tempDownPay_P is a temp field in the macro

Thank you all

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-03-03 06:33:40 +0200

Seen: 32 times

Last updated: Mar 03