473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do I make a function/sub so that I can run it from multiple forms?

I have a function in my database that I want to use in multiple forms. How can I set up my function so that I can just call it in each form? And how do I call it in my form code?

For example, here's a generic function:
Expand|Select|Wrap|Line Numbers
  1. Public Function genericMessage()
  2.    MsgBox "Here's my message"
  3. End Function
  4.  
I then want to call this function from multiple forms like this:

Expand|Select|Wrap|Line Numbers
  1. Private sub button1_Click()
  2.    genericMessage
  3. End sub
  4.  
My goal for this is so I don't need to retype my function script for each form. I'd rather just call the same function from different forms.
May 15 '13 #1
3 1127
Seth Schrock
2,965 Expert 2GB
Just put the function in a new module and then you will be able to call it from anywhere in your database.
May 15 '13 #2
Seth, thank you so much!
May 15 '13 #3
Seth Schrock
2,965 Expert 2GB
No problem. Glad I could help.
May 15 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sam Berry | last post by:
I am in need of some guidance on asscessing the same data from multiple forms. I tried using a collection, but everytime that I try to access the collection, I have to use the new word. colStuff...
10
by: SHPsalm139 | last post by:
We have an Access 2K application that uses multiple forms. We currently hardcode the release number in a label on each form but this gets tedious to do each time there's a new release. I thought...
0
by: question | last post by:
Hi! I have a requirement where I need to display multiple forms one after the other like a slide show. These are in the same application. Basicall on selection of a menu item it should start...
6
by: Garetht | last post by:
Hi, I am helping with the build of our database but I am in the UK and the other guy is in the US so it is quite hard to get things done!!! Basically we have a database with loads of tables in...
5
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
2
by: yxktmp | last post by:
Hi; I have a main starting query for most of my reporting. I branch out from this query to other queries. This main query contains multiple form control filters (query criterias) . I want to use...
7
by: Paulers | last post by:
Hello all, I have 2 forms, form1 and form2. I am trying to store some objects in an arraylist and have the arraylist be accessible by both forms. How would I go about doing that? I think I might...
2
by: goresus | last post by:
Hello, I have prepared a form and it is in its final stage. One thing that remains is the following: when I click a submit button in the page, all the information in the page, from different...
2
by: RAKESH BALAIAH | last post by:
Hi, I'm using an HTML page in which i've 2 forms which have the same action.. Ex: <form name="f1" action="store.jsp" method="post"> <!-- Do something --> </form> <form name="f2"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.