Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: VBA : Predefine parameters for a sub

    Hello,

    I have following question.
    When using a default sub or function, access sometimes presents the possible values of the parameters which will be passed.

    for example : As soon as I write 'Weekday(' --> access shows me that I have to fill in 'Date' and 'FirstDayOfWeek'

    When I get to the 'FirstDayOfWeek'parameter it even shows me a list of possible values (vbMonday, vbTuesday, ....)

    How can I write a sub or function and also present the possible values to the guy who is using the sub?

    Hope my explanation is clear.

    Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    Check out Enums in the VBA help.

    HTH

  3. #3
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243
    Hi,

    Tried using Enums and is working OK.
    But I'm still wondering if how I could get the list of predefined days (like vbMonday, vbTuesday, ...)
    I can create an enum again with these days, but it seems a bit silly because it already exists one way or another.

    Thanks

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    You need to start looking in the object browser. I'll talk you through this one
    • Open VBA IDE
    • Hit F2
    • Change the upper of the two combo boxes to VBA (just filters things)
    • Scroll down the classes
    • Notice that the bottom classes have a yellow icon - two boxes next to each other, one raised? That's the enum icon.
    • Click on VbDayOfWeek
    • Ta da!
    So - how do you use it? Just like your own enum.
    Code:
    Sum EnumExample (MyInput AS VbDayOfWeek)
    HTH

Posting Permissions

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