473,803 Members | 3,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Really stupid N00b question

When you use a function like I see posted here often, like:

Public Function Whatever()
stuff...
End Function

What do you actually do with that to make it run? I assumed you put it in a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

Maybe someone can show me where to start reading on using funcitons? I start
looking through the help files but quickly get overwhelmed. Seems like
almost all subjects start past the point of square 1, like you're already
supposed to know a bunch of things before help topics even get going.

May 1 '06 #1
7 1632
You can type Whatever() in the inmediate window (CTR+G) to see what it
does, or run it in any procedure in your project, again just by typing
its name

May 1 '06 #2
There are various ways to make your public functions run;
From the Immediate window to make the example functionrun, type the following and press enter;

?whatever

To get it to run from an event, within the VBA window of the
form/report you could put the following in the chosen event;

Call Whatever

The function is run when the event is fired.

I'm sure there are others who can explain this more elegantly and
expand on your question.

Hope this helps though.

Cheers

Phil

Alan wrote: When you use a function like I see posted here often, like:

Public Function Whatever()
stuff...
End Function

What do you actually do with that to make it run? I assumed you put it in a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

Maybe someone can show me where to start reading on using funcitons? I start
looking through the help files but quickly get overwhelmed. Seems like
almost all subjects start past the point of square 1, like you're already
supposed to know a bunch of things before help topics even get going.


May 1 '06 #3
Hi, Alan.
What do you actually do with that to make it run? I assumed you put it in
a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.
If it's a function or subroutine that doesn't accept any parameters, then
you can test it by placing your curson on the first line of the procedure:

Public Function Whatever() As String

.. . . and then hit the Run button (or hit <F5> or use the Run -> Run
Sub/UserForm menu), to run the procedure. If the procedure accepts
parameters, then you'll have to call this procedure from another. For
example:

Public Sub testingWhatever ()
Dim myVariable As String
myVariable = "today"
MsgBox Whatever(myVari able)
End Sub

.. . . and just place the cursor on the first line of testingWhatever () and
then hit Run to find out what "today" brings you.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"Alan" <Al********@msn .com> wrote in message
news:97******** ***********@216 .196.97.136... When you use a function like I see posted here often, like:

Public Function Whatever()
stuff...
End Function

What do you actually do with that to make it run? I assumed you put it in
a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

Maybe someone can show me where to start reading on using funcitons? I
start
looking through the help files but quickly get overwhelmed. Seems like
almost all subjects start past the point of square 1, like you're already
supposed to know a bunch of things before help topics even get going.

May 1 '06 #4
"Alan" <Al********@msn .com> wrote in message
news:97******** ***********@216 .196.97.136...

What do you actually do with that to make it run? I assumed you put it in
a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

If the cursor is not within a procedure, VBA does not know what procedure to
run, so it gives you the popup to select from.

John... Visio MVP
May 2 '06 #5
Hi, John.

Even if the cursor is within a procedure when the Run button is hit, the
popup asking for a macro name can still show up. It happens with class
modules and with procedures that require parameters.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"John Marshall, MVP" <la******@stone henge.ca> wrote in message
news:35******** ************@ma gma.ca...
"Alan" <Al********@msn .com> wrote in message
news:97******** ***********@216 .196.97.136...

What do you actually do with that to make it run? I assumed you put it
in a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

If the cursor is not within a procedure, VBA does not know what procedure
to run, so it gives you the popup to select from.

John... Visio MVP

May 2 '06 #6
True. I was trying to explain why the popup was there without going into too
much details on the exceptions. The cursor can be within a procedure that
does not have parameters, but if the window does not have focus, VBA will
give the popup.

John... Visio MVP
"'69 Camaro" <Fo************ **************@ Spameater.orgZE RO_SPAM> wrote in
message news:w-*************** *************** @adelphia.com.. .
Hi, John.

Even if the cursor is within a procedure when the Run button is hit, the
popup asking for a macro name can still show up. It happens with class
modules and with procedures that require parameters.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"John Marshall, MVP" <la******@stone henge.ca> wrote in message
news:35******** ************@ma gma.ca...
"Alan" <Al********@msn .com> wrote in message
news:97******** ***********@216 .196.97.136...

What do you actually do with that to make it run? I assumed you put it
in a
module. If I do that and hit the run sub/user form button I get a popup
asking me for a Macro Name. I'm not sure what to do from here.

If the cursor is not within a procedure, VBA does not know what procedure
to run, so it gives you the popup to select from.

John... Visio MVP


May 2 '06 #7
Hi, John.

I learn something new every day. Thanks for testing that. It would never
occur to me to run a procedure from the VB Editor during testing that I
wasn't currently looking at.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"John Marshall, MVP" <la******@stone henge.ca> wrote in message
news:3r******** *************** *******@magma.c a...
True. I was trying to explain why the popup was there without going into
too much details on the exceptions. The cursor can be within a procedure
that does not have parameters, but if the window does not have focus, VBA
will give the popup.

John... Visio MVP
"'69 Camaro" <Fo************ **************@ Spameater.orgZE RO_SPAM> wrote
in message news:w-*************** *************** @adelphia.com.. .
Hi, John.

Even if the cursor is within a procedure when the Run button is hit, the
popup asking for a macro name can still show up. It happens with class
modules and with procedures that require parameters.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"John Marshall, MVP" <la******@stone henge.ca> wrote in message
news:35******** ************@ma gma.ca...
"Alan" <Al********@msn .com> wrote in message
news:97******** ***********@216 .196.97.136...

What do you actually do with that to make it run? I assumed you put it
in a
module. If I do that and hit the run sub/user form button I get a
popup
asking me for a Macro Name. I'm not sure what to do from here.
If the cursor is not within a procedure, VBA does not know what
procedure to run, so it gives you the popup to select from.

John... Visio MVP

May 2 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1788
by: Matt | last post by:
I'd like to overwrite just one line of a binary file, based on a position set by seek(). Is there no way to do this? As far as I can tell I need to read the whole file, change the line, and write it all back out. Not exactly easy on the memory, but I see no other solution. so far: patchme.seek(offset) patchme.write(a2b_hex(edit)) # the data is in hex first patchme.close
3
1533
by: Anupam Kapoor | last post by:
hi all, a python n00b, so please bear with me. i have a simple question: i generally name python sources as a-simple-python-example.py. when i try to import a module named as above, i (obviously) get tracebacks from python interpreter. is there a way to continue naming python sources as above, and still use it as python modules ? i can ofcourse change the name to
1
1544
by: newgenre | last post by:
I am using a pre-built package of code for my site, which is called EasyDisc. All it does is it creates an interactive forum on your site, like any forum you see anywhere. I am having a problem getting started as I am new to .NET and sql. The app, once unzipped, tells me to "Make note of your SQL server name, username, password, database name. You need to supply these info. later." My problem is I don't know where to find out that info....
4
10146
by: onefry | last post by:
Hey I have this prog that i'm working on, starting my first c++ class and kind of a n00b to programming here it is #include <iostream> #include <cstdlib> using namespace std;
6
1506
by: Charles | last post by:
I am learning from the Accelerated C++ book. The following example doesn't work and I don't know why: #include <iostream> #include <string> int main () { const std::string exclam = "!"; const std::string message = "Hello" + ", world" + exclam; return 0; }
56
2997
by: tasteless | last post by:
Hi guys, I need really hard questions (about 10) about PHP programming (some of elements OOP as well, but no MySQL questions - this is different part), this questions needs to be very hard, but the experienced senior PHP developer should answered on it. I've already searched in google and google groups archive but without any good results. So could anybody help me giving some link or sending some stuff to me ?
3
1328
by: rtlshred | last post by:
Hello I have just, just started C++ programing. the complier I am using is Dev C++ Here is my question: Once I have written some code, How do I run the program and see the output?
2
4231
by: benwah1983 | last post by:
Greetings, Here is my problem: The following code shows a div with two small nested divs (images with a title), then the div is closed. Another one opens and a "random text" is displayed. <div style="width: 500px;"> <div style="float: left; padding: 20px;"> Image Title 1<br/> <img src="test.jpg"/> </div> <div style="float: left; padding: 20px;">
9
1610
by: Alec | last post by:
Sorry guys, stupid question.... Am no programming expert and have only just started using php for creating dynamic news pages. Then I see a dynamic website without the php extension. http://www.newcarnet.com/Alfa%20Romeo_news.html?id=8380 It has the html extension that loads the required page dynamically.
0
9566
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10300
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7607
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.