Solved

Multiple command buttons sharing one event?

Posted on 1998-09-06
6
192 Views
Last Modified: 2006-11-17
Let's say that I have 5 command buttons on an Access 97 form.  All five buttons perform pretty much the same tasks, with one exception.  Rather than use 5 "OnClick" events, is it possible for all 5 command buttons to use one and the same event?  If 'yes', then how?  Then, how can I perform a Select Case within this single event to determine which button of the 5 that actually triggered the event?  This way I can minimize the amount of duplicate coding, while at the same time make sure that the unique code related to each command button is run.
0
Comment
Question by:Monroe406
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Helicopter
ID: 1961340
create a function (say myfunction()) which takes a string as a parameter

call the function from the onclick events of your 5 buttons and pass the name of the command button with it.

If the uniqueness can be further refined you only need to pass the element that is unique to the function, the actual command button name isn't necessary
0
 

Author Comment

by:Monroe406
ID: 1961341
Thanks.

I wanted to ask some new questions, however, it looks like Experts Exchange's "Ask a ?" function is temporarily broken:

File Not Found

The requested URL /topics/bin/NewQForm was not found on this server.

In any case, here are some new questions:

1) How does one define a GLOBAL constant value that is accessible from ALL modules/forms?

2) How can I check whether a file for input exists PRIOR to opening it?  Likewise, how can I verify whether a directory exists or not?  In Delphi/Pascal, it would be "If FileExists("c:\autoexec.bat") then...".  In PowerBasic, it would be "Dir$("c:\autoexec.bat")".

0
 
LVL 5

Accepted Solution

by:
kulikuli earned 50 total points
ID: 1961342
Public constant for all modules/forms:
In a standard module: Public const MYCONSTANT as string="mystringvalue"
File exits check:
use the Dir() function. if it generates an error the directory does not exist. If no error occures you are able to determine if the file you want to create already exist.

Best regards,

kulikuli
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:Monroe406
ID: 1961343
Since it is still impossible to ask a new question via "Ask a ?"

--------------
File Not Found

       The requested URL /topics/bin/NewQForm was not found on this server.
--------------

.I am going to press my luck and ask another question here:

Is there a way to retrieve the value of a Text component withOUT having to SetFocus first?  Currently, this is illegal:

MyString = Text1.Text

.unless I do this first:

Text1.SetFocus
MyString = Text1.Text

Is there a more efficient solution?  Setting focus prior to referencing the Text component's data won't always work, as in...

MyString = Text1.Text + " " + Text2.Text

Thanks.
0
 
LVL 8

Expert Comment

by:Helicopter
ID: 1961344
Try putting me before hand

MyString = me.Text1 & " " & me.Text2

you shouldn't need to set focus.
0
 

Author Comment

by:Monroe406
ID: 1961345
Thanks Helicopter!  That worked great!

0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question