Results 1 to 3 of 3
  1. #1
    Zellax is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    6

    How do I make a VBA funtion Global?

    I didn't make this database. I am a poor hapless fool who got shoved into a DBA position with no previous experience with Access at all. I apologize if this is just too simple but this question of function scope seems to be beneath any of the guides I've found online.

    I am trying to make a function that can be called from either a text box or an on-click event in multiple forms that runs a custom search function. I named the function
    Code:
    Public Function SearchFunc() As Variant
    but I keep getting an error that Access can't find this function when called in a Macro. It is located in a VBA module named [Functions] but that very well may be a module a previous developer put into this database. Can you make a function global?

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    If a function is in a stand-alone module, i.e. not attached to a form or report, then it is a global function. Remove the As Variant

  3. #3
    Zellax is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    6
    Thanks, that fixed it.

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

Similar Threads

  1. Replies: 4
    Last Post: 02-18-2017, 05:45 AM
  2. Replies: 5
    Last Post: 01-30-2015, 08:57 PM
  3. Replies: 7
    Last Post: 08-23-2014, 05:52 AM
  4. FileCopy Funtion
    By dccjr in forum Programming
    Replies: 2
    Last Post: 04-18-2013, 09:04 PM
  5. Random Rdn() Funtion Help Please
    By graviz in forum Access
    Replies: 1
    Last Post: 12-09-2009, 11:57 AM

Tags for this Thread

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