Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2012
    Posts
    126

    Unanswered: Calling a Module

    No idea what im doing wrong but im tired or retyping the same code over and over.

    Basically I have a close buttons throughout my databases that close the form and make the dashboard visible. IE:

    Private Sub cmdClose_Click()
    DoCmd.Close
    Forms!frmdashboard.Visible = True
    End Sub
    Simple enough but doing this over and over for every database gets a bit redundant. I tried my hand at a module that i named CloseToDashboard

    Option Compare Database
    Option Explicit

    Public Sub cmdClose()
    DoCmd.Close
    Forms!frmdashboard.Visible = True
    End Sub
    I can't for the life of me figure out how to call this from a button though. Please help.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I assume that you're talking about this being in a Standard Module, i.e. not in a Form's Module.

    In Access, you don't Call a Module, as your thread title suggests, you Call the Sub or Function that is in a Standard Module.

    In this case it would simply be

    Code:
    Private Sub YourButtonName_Click()
     cmdClose
    End Sub

    Also note that you must never give the Module the same name as a Sub or Function that resides in the Module; it'll confuse the Access Gnomes no end and cause them to throw an error at you!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Aug 2012
    Posts
    126
    Damn those access gnomes!! LOL

    Thanks a million as always ling, got it working

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Glad we could help!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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