473,491 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to program your own macro feature?

99 New Member
I want to build a feature into an access form that works like a macro...

The user clicks a button to trigger the program to start "recording" button events. Then the user goes through a series of common steps on the form that mostly involves hitting additional buttons. While the user hits these buttons, the program is saving events in a table. When the user finishes his work, he presses another button to end the "recording" process.

Now the user can hit a "play" button and the access form will automatically repeat all the events that were recorded.

I understand how to accomplish most of this but I don't know how to write a subroutine that calls another subroutine through a variable. Something like this...

Call VariableThatHoldsNameOfSubroutines

If I try something like this, Access assumes the variable is actually a subroutine and gives me an error.

I hope I explained this well enough that someone understands. Does anyone know how to address this?
Oct 1 '09 #1
4 1339
MikeTheBike
639 Recognized Expert Contributor
Hi

Of the top of my head I would write a sub that takes an argument to determine which Sub is Run. So, based on you post something like

Call MainSub(VariableThatHoldsNameOfSubroutines)

and Sub MainSub would look like this

Expand|Select|Wrap|Line Numbers
  1. Sub MainSub(ByVal SubNumberVariable as Integer)
  2.     Select Case SubNumberVarable
  3.         Case is = 1
  4.             SubOne
  5.         Case is = 2
  6.             SubTwo
  7.         etc......
  8.     End Select
  9.  
  10. End Sub
Is that the sort of thing that would do ?

Note the aurument can be defined as any data type but (IMO) integer/Long are best.


MTB
Oct 1 '09 #2
AdamOnAccess
99 New Member
LOL Simple!

I don't know why but I got hung up thinking that I needed something like an "execute" statement. But sure, I could define the buttons with integers, store the integers, and then run them through your select statement.

Sometimes I just can't see the forest through the trees!

Thanks,
Adam
Oct 1 '09 #3
NeoPa
32,556 Recognized Expert Moderator MVP
Depending on exactly how you plan to use this feature you may find Eval() can work for you.
Oct 1 '09 #4
FishVal
2,653 Recognized Expert Specialist
  • "Application.Run" method could be used.
  • "CallByName" method may be particularly useful for you since, I guess, the procedures you want to call reside in forms' modules.
Oct 1 '09 #5

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

Similar topics

10
1891
by: Mac | last post by:
Is there a way to mimic the behaviour of C/C++'s preprocessor for macros? The problem: a lot of code like this: def foo(): # .... do some stuff if debug: emit_dbg_obj(DbgObjFoo(a,b,c)) #...
21
2305
by: Eric | last post by:
Hello all, I've got this line of given code (cannot change this; wizard-generated, but value may change someday): #define IDB_BUTTON 225 Somewhere in the code I found /...
7
4907
by: Jim Cook | last post by:
We have a macro which takes various index constants as an argument and offsets into an array. The macro can be an Lvalue or Rvalue. The index is not zero based. I would like a compile time error...
20
2416
by: Jim Ford | last post by:
I understand that some compilers define a symbol that can be used anywhere in the code in order to find out, at run time, the name of the file where the code corresponding to the current execution...
21
2039
by: kimimaro | last post by:
Is there anymore methods in exiting your program using pure C language other than return 0?
19
16636
by: Mockey Chen | last post by:
I using #define as following: #include <stdio.h> #define LOG_PREFIX "Current function: <" __FUNCTION__ ">: " int main() { printf(LOG_PREFIX "some thing.\n"); return 0; }
20
21701
by: rkk | last post by:
Hi, Is there an equivalent typeof macro/method to determine the type of a variable in runtime & most importantly that works well with most known C compilers? gcc compiler supports typeof()...
21
2284
by: MAx | last post by:
Hi, Could any one list possible number of diferences between a function and a macro? which one will be faster and why?? ex : function and a macro ti find max of two nums #define MAX(a,b) (a>b)...
7
6021
by: skillzero | last post by:
Is there a way to cause a compile/preprocessor error in a macro if a preprocessor symbol is not defined? I want to do the equivalent of this in a macro: #if( !defined( SOME_FLAG ) ) #error not...
0
7154
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
7190
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...
1
6858
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...
1
4881
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...
0
4578
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...
0
3086
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...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.