locked
autoexc macro can only run functions NOT sub? In access 2013 win 7 64 bit? RRS feed

  • Question

  • autoexc macro can only run functions NOT sub? In access 2013 win 7 64 bit?

    That is what it seems to me. As far as I can tell.

    I needed a autoExc file to run code every time Access started up.

    created a macro, renamed it autoexc. It did run every time Access started.

    couldn't find way to have line in VBA 7.1 that sets an option.

    so used RunCode in macro wizard (had drop down lists of all that could do in a macro)

    I could not figure out how to run a sub (just had lines, each line was setting one option.   Like No Auto correct.

    When I replaced the Sub with a Function (all lines the same in both Sub or Function)

    then had changed the macro autoexc line RunCode to the name of the Function.

    All run perfectly, Autoexc ran on start of Access, Then the Function was run, running the lines Setting the options.

    I did not have the Function return ANY thing.

    1. I couldn't find out how and IF I could run statements in autoexc macro without the Function.

    2. I also couldn't find out IF reason I couldn't have macro run a Sub instead of Function.

    Any info on # 1 or # 2 as to why, or how I should have done the code, I will be thankful for.

    Mark J


    Mark J

    Tuesday, June 7, 2016 5:59 PM

Answers

All replies

  • Hi Mark. You are correct. Macros can only run public functions. So, in my humble opinion, you did the right thing. Cheers!
    Tuesday, June 7, 2016 6:11 PM
  • Hi PuzzledByWord,

    I agree with .theDBguy that macro can run functions so you can try to continue with your work around because it is not possible to run sub.

    Hope you get your answer so I would recommend you to mark the suggestion given by .theDBguy as an Answer.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 8, 2016 1:34 AM
  • theDBguy,

    Thanks.

    Mark J.


    Mark J

    Sunday, June 19, 2016 10:20 AM
  • Deepak,

    Thanks.

    So I don't feel stupid asking questions like this one.

    Do you have any ideas as to where I can find documentation on this subject.

    That is, about macros, especially where I can find info on bits like I cannot use a sub only a public function in a macro.

    I have the feeling there is a lot more items like this I need to know. Items, I didn't know I could do.

    Like can I somehow in a macro use a public function to assign a value to something, (to a variable in the macro, or outside macro) and what are those somethings.

    I don't know what are the limits are, or the possibilities are either in using a macro.

    So links to info about macros, and their limits and possibilities will be very helpful.

    Mark J


    Mark J

    Sunday, June 19, 2016 10:40 AM
  • Hi Mark. If you don't mind me asking... Why the need to learn macros? VBA is more powerful than macros. Do you already know VBA and just want to learn macros? Just curious...
    Monday, June 20, 2016 4:47 AM
  • Hi PuzzledByWord,

    There is no Microsoft Documentation is available for this particular subject(cannot use a sub only a public function in a macro).

    but information is available on the internet. you need to use different search engines to find information.

    also some of the things you can only get aware by using and testing it by yourself.

    if you want to learn a macro from starting then you can find many links like below. you can start from there.

    Quick start: Create a macro

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, June 20, 2016 7:07 AM