Results 1 to 4 of 4
  1. #1
    ShostyFan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    76

    Public Function

    I have a lot of code in a cash register program that has to repeat itself so I am looking to call the code in a public function for all the good reasons that exist with that.


    I can't seem to get the syntax correct for what I want to do. Here is a simple version that I can't get working (the msgBox works, but the make button visible line gives me an errror:

    In the Cash Register form I have:

    Private Sub testButton_Click()
    Call myViews
    End Sub


    Then in the Modules I have:
    Public Function myViews()
    MsgBox "hello"
    Forms![Frm Cash Register]!testButton.Visible = False
    End Function

    Any and all help will be greatly appreciated.
    Thanks.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You don't say what the error is, but the button still has focus. You'd have to move focus elsewhere before hiding it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ShostyFan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    76
    Okay, so that just happened....
    I moved focus, and all is good.
    Thanks.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. VBA Can't find Public Function
    By GraeagleBill in forum Programming
    Replies: 15
    Last Post: 03-17-2016, 09:38 PM
  2. Public variable not updating for each function
    By Ruegen in forum Programming
    Replies: 3
    Last Post: 08-28-2014, 06:26 PM
  3. Pass DAO.Recordset into public function
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 07-07-2014, 12:31 AM
  4. Making a Public Function more flexible
    By sjs94704 in forum Programming
    Replies: 2
    Last Post: 12-10-2012, 02:21 PM
  5. Replies: 9
    Last Post: 12-20-2010, 08:05 PM

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