Solved

Multiple command buttons sharing one event?

Posted on 1998-09-06
6
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sIMULTANEOUS USAGE ON NETWORK-ACCESS 2010-2013 7 77
Handle Apostrophes in SQL Parameter 16 67
Access Query function 4 51
Why Won't My Excel Workbook Refresh The Data 2 46
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

734 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