Ask Your Question
0

Calling Several Sub(s) from another Sub in Base Macro --Error 91

asked 2020-03-19 17:39:45 +0200

MQ-818 gravatar image

updated 2020-03-23 19:23:20 +0200

I have several Subs (13 in total) in a module that are all working individually. The way they are designed to work is in sequential order.
Here is an example: Sub 1 do something, Sub 2 other thing....Sub 13 display final result

My issue is...Let's say I change some value in sub 4, Now I have to click through 5 to 13 to get the intended result. So, Now that everything is working, to make life simpler I am creating a MASTER button that will just run all the subs.

Below is a sample of one of my working sub and the master-sub (error-91)

EXACT ERROR MESSAGE: [BASIC runtime error. '91' Object variable not set]

Sub Calculate_ALL_Entries

DownPay_In_Percent

End Sub

REM....1. CALCULATE THE DOWNPAYMENT PERCENTAGE

Sub DownPay_In_Percent(oEvent as Object)

    dim oForm as Object
    dim oSubForm as Object
    dim tempP_SalesPrice as double  
    dim tempDownPay as double
    dim tempDownPay_P as double

    oForm = oEvent.Source.Model.Parent
    REM...// oForm = ThisComponent.Drawpage.Forms.getByName("subfrm_PropertyCal") 

    tempP_SalesPrice = oForm.getByName("txtP_SalesPrice").currentvalue
    tempDownPay = oForm.getByName("txtCal_DownPay").currentvalue
    tempDownPay_P = (tempDownPay / tempP_SalesPrice) * 100
    oForm.getByName("txtCal_DownPay_P").text = tempDownPay_P
    oForm.Columns.GetByName( "Cal_DownPay_P" ).updatedouble(tempDownPay_P,3) 'Use 1 to 17 here '         
            REM...//  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-19 19:14:30 +0200

MQ-818 gravatar image

Thank You Ratslinger.

Here is my working Macro Code based on your proposed solution.

Sub Calculate_ALL_Entries (oEvent as Object)

    dim oForm as Object
    oForm = oEvent.Source.Model.Parent

    DownPay_In_Percent(oForm)

End Sub

'1. CALCULATE THE DOWNPAYMENT PERCENTAGE

Sub DownPay_In_Percent (oForm as Object)

    dim tempP_SalesPrice as double  
    dim tempDownPay as double
    dim tempDownPay_P as double

    tempP_SalesPrice = oForm.getByName("txtP_SalesPrice").currentvalue
    tempDownPay = oForm.getByName("txtCal_DownPay").currentvalue
    tempDownPay_P = (tempDownPay / tempP_SalesPrice) * 100
    oForm.getByName("txtCal_DownPay_P").text = tempDownPay_P
    oForm.Columns.GetByName( "Cal_DownPay_P" ).updatedouble(tempDownPay_P,3) 'Use 1 to 17 here 

    REM....///      MsgBox("Down payment % is "& tempDownPay_P)

End Sub

edit flag offensive delete link more
0

answered 2020-03-19 17:54:49 +0200

Ratslinger gravatar image

Hello,

From what is shown, you are calling DownPay_In_Percent but the Sub is defined as requiring an argument (oEvent).

In future also indicate the line which was noted for the error.

edit flag offensive delete link more

Comments

Thank you Ratslinger You are correct It solved the problem.

For the newbies like me.....I am going to post my final working Macro Code at the Solution

MQ-818 gravatar imageMQ-818 ( 2020-03-19 19:10:02 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-03-19 17:39:45 +0200

Seen: 43 times

Last updated: Mar 23