Page 1 of 1

[Solved] Run 2 macros from one event?

PostPosted: Wed Jul 11, 2018 12:15 pm
by Maax555
Is it possible to run 2 macros from one event?
I have the below macro running from item status changed in my txtCustomer listbox. This updates my txtSimilarPart listbox.
I want a second macro to run from the same txtCustomer listbox for the same item status changed event which updates my txtReplaces listbox.
My Macros is
Sub CustChange
oForm1 = ThisComponent.Drawpage.Forms.getByName("MainForm") 'Get Form
oField = oForm1.getByName("txtCustomer")
sSelectedValue = oField.SelectedValue
sSql = "SELECT ""PartNumber"" FROM ""PartNumber"""&_
" WHERE ""CustomerID"" = '" & sSelectedValue & "' ORDER BY ""PartNumber"" ASC"
oField = oForm1.getByName("txtSimilarPart")
oField.listsource = array(sSql)
oField.refresh()
End Sub


For the second Macro I would just change to ("txtReplaces")

So can i create a macro for example Sub 2Macros that runs the two macros i need to run or do I build the two macros into one?
If i make the two macros into one is it as simple as just pasting in the second macro before the end of the End Sub?


many thanks

Re: Run 2 macros from one event?

PostPosted: Wed Jul 11, 2018 12:53 pm
by John_Ha
Maax555 wrote:Is it possible to run 2 macros from one event?

Run one macro ... which runs the two macros you want to run. They will be in sequence, not parallel.

Showing that a problem has been solved helps others searching so, if your problem is now solved, please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.

Re: Run 2 macros from one event?

PostPosted: Wed Jul 11, 2018 1:01 pm
by Maax555
Hi John, thanks for quick reply. As I am not sure how to create the macro that runs the other two i tried the cut and past method. This actually worked to my surprise. However I would rather have them separate. Are you able to advise how to write the macro i need?
thanks again.

Re: Run 2 macros from one event?

PostPosted: Wed Jul 11, 2018 1:11 pm
by Maax555
ok, so i tried this and it seems to work which worries me when i do something and it works first time.

Sub CustChangeSimRep
CustChangeSimilar
CustChangeReplaces

End Sub

is it really that simple?

Re: Run 2 macros from one event?

PostPosted: Wed Jul 11, 2018 7:33 pm
by John_Ha
Maax555 wrote:is it really that simple?

Yes!

Alternatively, just paste the commands from macro_2 into macro_1 so you have one macro.

Showing that a problem has been solved helps others searching so, if your problem is now solved, please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.