Results 1 to 3 of 3
  1. #1
    Soule is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2011
    Posts
    58

    Can I Enter Sub Name In On Click Property?

    Hi, Everyone,

    I want to click a form button and run code in a STANDARD module (not the "behind the form" class module).

    Can I enter the name of that Public Sub in the On Click Property box?



    Pointing a button to code doesn't always have to be done with the "Event Procedure" option filled in the On Click Property box, correct?

    I have a Public Sub in a standard module that my form button doesn't seem to see, even though the name of the button and the Sub are different.

    Any bit of information to clear this up for me will be appreciated. Thanks.

    Frank

    This post is also here http://www.utteraccess.com/forum/Ent...-t1983327.html
    and here http://www.access-programmers.co.uk/...d.php?t=222613

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Soule View Post
    Hi, Everyone,

    I want to click a form button and run code in a STANDARD module (not the "behind the form" class module).

    Can I enter the name of that Public Sub in the On Click Property box?

    Pointing a button to code doesn't always have to be done with the "Event Procedure" option filled in the On Click Property box, correct?

    I have a Public Sub in a standard module that my form button doesn't seem to see, even though the name of the button and the Sub are different.

    Any bit of information to clear this up for me will be appreciated. Thanks.

    Frank

    This post is also here http://www.utteraccess.com/forum/Ent...-t1983327.html
    and here http://www.access-programmers.co.uk/...d.php?t=222613

    Answered in the other posts, so I'll give a different option.

    You CAN call a sub in a standard module, but you have to use an Event procedure.
    Set the "On Click" property of the button to [Event Procedure] ; the code would look like:

    Code:
    Private Sub cmdYourButtonName_Click()
       Call SetBase
    End Sub
    where "SetBase" is the name of your sub in the standard module.

  3. #3
    Soule is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2011
    Posts
    58
    Solved:

    Thanks, AGAIN, SSanfu!

    I went with your method because I've never written a Function procedure before.

    I decided to change my names back...they're all different now. I should probably have prefixed them like someone else suggested (such as Public Sub modulename.subname), but I don't really need to now...next time.

    I used Event Procedures in my Event property to point to them.

    Thank you.

    Frank

Please reply to this thread with any new information or opinions.

Similar Threads

  1. RecordLocks Property
    By JackieEVSC in forum Forms
    Replies: 5
    Last Post: 11-16-2011, 01:51 PM
  2. Check/Uncheck Checkbox on "Enter" click
    By emilyrogers in forum Forms
    Replies: 2
    Last Post: 02-17-2011, 10:24 AM
  3. Replies: 5
    Last Post: 02-06-2011, 04:32 PM
  4. SQL vs. vba Row Source property
    By eww in forum Programming
    Replies: 7
    Last Post: 10-15-2010, 11:02 AM
  5. Create Property
    By RAPSR in forum Programming
    Replies: 2
    Last Post: 10-12-2010, 12:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums