?
Solved

Multiple command buttons sharing one event?

Posted on 1998-09-06
6
Medium Priority
?
201 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 200 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

770 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