Results 1 to 15 of 15
  1. #1
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run Module using macro? (Access 2000)

    How can I run a module straight from the switchboard? I know I have to use a macro but what command do I use? I need urgent help, PLEASE help. Thank you.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    In the Edit SwitchBoard Item window, enter 'Run Code' in the Command Combobox.
    In the Textbox Function Name enter the name of your function or Sub
    Francois

  3. #3
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    Hiya, Thank you for the help, but I've already tried that and it doesn't work.
    any other suggestions?

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    What is happening when you click on the switchboard item ?
    Do you receive an error message ? If yes, which one?
    Do you try to stepping through your code?
    Francois

  5. #5
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    The code is working perfectly fine when I go open the module and run it using the command button on the tool bar, but when I click on the button on the switchboard it give me the following error message: There was an error executing the command.
    The name of the module is "CreateClassicReport". Do I put that in the function name or do I put "Sub CreateClassicReport ()" coz I tried both and it gives me the same error. What is wrong?

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    You have to use the name of the sub without the word 'Sub' or 'Function' and without brackets:

    CreateClassicReport

    Not the name of the module.
    Francois

  7. #7
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    But why is it giving me the error? Do you have any idea? Thank you.

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    When you create a function or a sub you give it a name.
    Sub test()
    Function test()
    The 'Sub' or 'Function' is to make it a subroutine or a function but is not part of the name.
    The brackets are only neaded for passing arguments.
    When you enter in the swichtbourd 'Sub Test', Access look for a sub or function with the name 'Sub test'. If it was possible it have to look like this in a Module :
    Sub Sub test
    ...
    End Sub
    Compare it to a form you have to fill in:
    Name: Francois Caron
    My name is 'Francois Caron' and not 'Name: Francois Caron'
    Francois

  9. #9
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    I understood the firstime u said it but even if I type in the function name : CreateClassicReport, it gives me an error, do you know why? thank you

  10. #10
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    Do you have a second copy of you sub with the same name in another module ?
    If yes, rename it or delete it.
    Sub names must be unique over all the database.
    Francois

  11. #11
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    That is the only module I've got, so I really don't know whats happening.

  12. #12
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    I don't see anything more without seeing the database <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>
    If you want, you may attach you MDB
    I'll have a look at it.
    If it is to big for the lounge(100K), you can send it to my mail address fcaron@pandora.be
    Francois

  13. #13
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    Check your mail.

  14. #14
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    Two errors in your mdb:
    - the name of the sub is the same as the name of the module. That confuse Access. Rename your module to anything else.(ex mdlCreateClassicReport)
    - don't make your sub 'Private'. If you make a sub private, this sub can only be called from within the module where it is. Remove the word 'Private' before Sub
    Francois

  15. #15
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Module using macro? (Access 2000)

    THANK YOU SOOOOOOOOOOOOOO MUCH, It finally works. Sorry I'm not very good at Visual basic ( Actually am not good at all) <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •