473,327 Members | 1,967 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,327 software developers and data experts.

calling a function

Hi (again) ;-)

I'm still very much at the bottom of a steep learning curve with VB, so
any and all help is always appreciated.

I've found some code to generate the user names who have logged onto the
file in question and from what I've been reading it will do what I
need. However, what is eluding me is the "calling" it bit. If anyone
can put into simple terms what is needed & general principles I would be
really grateful.

Do you need to create a form that is populated by the function? Have or
am I totally missing the plot?

Stinky Pete ;-)
Feb 13 '07 #1
5 7833
Stinky Pete wrote:
Hi (again) ;-)

I'm still very much at the bottom of a steep learning curve with VB, so
any and all help is always appreciated.

I've found some code to generate the user names who have logged onto the
file in question and from what I've been reading it will do what I
need. However, what is eluding me is the "calling" it bit. If anyone
can put into simple terms what is needed & general principles I would be
really grateful.
Do you need to create a form that is populated by the function? Have or
am I totally missing the plot?

Stinky Pete ;-)
A form can be bound (table/query in recordsource) or unbound (not
associated with table/query).

There are events that are executed; Open, Current, BeforeUpdate, etc.
Events are where you'd put your code. You need to determine which event
would be best when calling your code/macros.

You can click on the events tab, move to a row, and press F1 to get help
on the property to see what it does.

The OnCurrent event fires for each record you move to. If unbound, it
fires after the open/load events. Maybe that's where you need to call
your code.
Feb 13 '07 #2
On Feb 14, 12:55 am, salad <o...@vinegar.comwrote:
Stinky Pete wrote:
Hi (again) ;-)
I'm still very much at the bottom of a steep learning curve with VB, so
any and all help is always appreciated.
I've found some code to generate the user names who have logged onto the
file in question and from what I've been reading it will do what I
need. However, what is eluding me is the "calling" it bit. If anyone
can put into simple terms what is needed & general principles I would be
really grateful.
Do you need to create a form that is populated by the function? Have or
am I totally missing the plot?
Stinky Pete ;-)

A form can be bound (table/query in recordsource) or unbound (not
associated with table/query).

There are events that are executed; Open, Current, BeforeUpdate, etc.
Events are where you'd put your code. You need to determine which event
would be best when calling your code/macros.

You can click on the events tab, move to a row, and press F1 to get help
on the property to see what it does.

The OnCurrent event fires for each record you move to. If unbound, it
fires after the open/load events. Maybe that's where you need to call
your code.
Thanx for the info. It's helped and I will keep looking and playing
to understand this better. As mentioned, this type of thing is really
new to me so there may be a few more posts ;-)

Stinky Pete ;-)

Feb 13 '07 #3
Stinky Pete wrote:
On Feb 14, 12:55 am, salad <o...@vinegar.comwrote:
>>Stinky Pete wrote:
>>>Hi (again) ;-)
>>>I'm still very much at the bottom of a steep learning curve with VB, so
any and all help is always appreciated.
>>>I've found some code to generate the user names who have logged onto the
file in question and from what I've been reading it will do what I
need. However, what is eluding me is the "calling" it bit. If anyone
can put into simple terms what is needed & general principles I would be
really grateful.
Do you need to create a form that is populated by the function? Have or
am I totally missing the plot?
>>>Stinky Pete ;-)

A form can be bound (table/query in recordsource) or unbound (not
associated with table/query).

There are events that are executed; Open, Current, BeforeUpdate, etc.
Events are where you'd put your code. You need to determine which event
would be best when calling your code/macros.

You can click on the events tab, move to a row, and press F1 to get help
on the property to see what it does.

The OnCurrent event fires for each record you move to. If unbound, it
fires after the open/load events. Maybe that's where you need to call
your code.


Thanx for the info. It's helped and I will keep looking and playing
to understand this better. As mentioned, this type of thing is really
new to me so there may be a few more posts ;-)

Stinky Pete ;-)
Depending on your version of Access you might want to consider a book
like Microsoft Step By Step for the version. You won't learn much
unless you do the exercises. It's a good book for when you are starting
to work with coding in Access.
Feb 14 '07 #4
I believe there's even a Step by Step book for Microsoft Access VBA, not
just the end-user book. I used an early (Access 2.0) edition to teach a
class for Paradox DB users moving to Access 2.0 and I've had feedback that
current editions of the end-user book is very good for self-study. I haven't
had occasion to use or review the Step by Step book for Microsoft Access
VBA.

Larry Linson
Microsoft Access MVP
"salad" <oi*@vinegar.comwrote in message
news:Yv*****************@newsread4.news.pas.earthl ink.net...
Stinky Pete wrote:
>On Feb 14, 12:55 am, salad <o...@vinegar.comwrote:
>>>Stinky Pete wrote:

Hi (again) ;-)

I'm still very much at the bottom of a steep learning curve with VB, so
any and all help is always appreciated.

I've found some code to generate the user names who have logged onto the
file in question and from what I've been reading it will do what I
need. However, what is eluding me is the "calling" it bit. If anyone
can put into simple terms what is needed & general principles I would be
really grateful.
Do you need to create a form that is populated by the function? Have or
am I totally missing the plot?

Stinky Pete ;-)

A form can be bound (table/query in recordsource) or unbound (not
associated with table/query).

There are events that are executed; Open, Current, BeforeUpdate, etc.
Events are where you'd put your code. You need to determine which event
would be best when calling your code/macros.

You can click on the events tab, move to a row, and press F1 to get help
on the property to see what it does.

The OnCurrent event fires for each record you move to. If unbound, it
fires after the open/load events. Maybe that's where you need to call
your code.


Thanx for the info. It's helped and I will keep looking and playing
to understand this better. As mentioned, this type of thing is really
new to me so there may be a few more posts ;-)

Stinky Pete ;-)
Depending on your version of Access you might want to consider a book like
Microsoft Step By Step for the version. You won't learn much unless you
do the exercises. It's a good book for when you are starting to work with
coding in Access.

Feb 15 '07 #5
On Feb 13, 8:55 am, salad <o...@vinegar.comwrote:
Stinky Pete wrote:
Hi (again) ;-)
I'm still very much at the bottom of a steep learning curve with VB, so
any and all help is always appreciated.
I've found some code to generate the user names who have logged onto the
file in question and from what I've been reading it will do what I
need. However, what is eluding me is the "calling" it bit. If anyone
can put into simple terms what is needed & general principles I would be
really grateful.
Do you need to create a form that is populated by the function? Have or
am I totally missing the plot?
Stinky Pete ;-)

A form can be bound (table/query in recordsource) or unbound (not
associated with table/query).

There are events that are executed; Open, Current, BeforeUpdate, etc.
Events are where you'd put your code. You need to determine which event
would be best when calling your code/macros.

You can click on the events tab, move to a row, and press F1 to get help
on the property to see what it does.

The OnCurrent event fires for each record you move to. If unbound, it
fires after the open/load events. Maybe that's where you need to call
your code.
As a relative newbie to this world, I still remember the confusion.
There are two types of basic calls.

Salad describes the first one where you use the event on the form to
"call" the code for that event. This is usually where people start
using VBA... after they've done a few macros and find that macros
can't do something.

The second type is when you've called VBA using the event on a form,
but... then you want to call an _additional_ code from your event
code. You usually do this because you want to use the same code in
multiple forms without having to copy it over and over again.

Basically, there are "sub"s and "function"s that you can "call". A
sub is basically code that executes and is done. A function looks
just like a sub... only you can send data to it, and receive data back
as an answer.

You can save these in the code for the form or report you're working
on. Or, you can save them for common use by multiple forms or
reports. To do this, save them in a module.

To "call" a sub or a function, you simply type

call functionname(firstvariable,secondvariable)
' or
call subname

within your code. That will cause the sub or function to execute.

If you have a function that returns a result, then you can also "call"
it by using it as a variable. Say you wrote a function called
"PullLastUser" that looked up the last user of an application. You
could make a button that had this code on the "OnClick" event...

msgbox "The last person to use this database was " &
PullLastUser("DatabaseName")

You could get fancy and let the user pick from a list of applications
in a dropdown. This would look more like...

strApplicationName = me!cmbApplicationName
strLastUser = PullLastUser(strApplicationName)

Access and VBA have some help files if you search for "call
statement", "sub statement" and "function statement". These might
help. But, they're short and cryptic. Personally, I learned a ton
from using sample code and reading this group. But, nothing really
clicked until I took a few classes from UMSL. Those were awesome, but
my company paid.

So, if Salad and Larry recommend the Step by Step books, then I'd jump
on them. Those guys know what they're talking about.

Jon

Feb 15 '07 #6

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

Similar topics

8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference...
14
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
2
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
11
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
16
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.