[Solved] Run 2 macros from one event?

Creating and using forms

[Solved] Run 2 macros from one event?

Postby Maax555 » Wed Jul 11, 2018 12:15 pm

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
Last edited by Maax555 on Thu Jul 12, 2018 9:05 am, edited 1 time in total.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
 
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Run 2 macros from one event?

Postby John_Ha » Wed Jul 11, 2018 12:53 pm

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.
AOO 4.1.6, Windows 7 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 6815
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Run 2 macros from one event?

Postby Maax555 » Wed Jul 11, 2018 1:01 pm

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.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
 
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Run 2 macros from one event?

Postby Maax555 » Wed Jul 11, 2018 1:11 pm

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?
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
 
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Run 2 macros from one event?

Postby John_Ha » Wed Jul 11, 2018 7:33 pm

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.
AOO 4.1.6, Windows 7 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 6815
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK


Return to Forms

Who is online

Users browsing this forum: No registered users and 2 guests