I have a sub that can do two different tasks based on the value of one
variable. So I'd like to have two different buttons on the same form run
this, but each one setting a flag so that the conditional logic knows which
one to run.
Here is what I have in mind:
If Button_One_Was_ Pressed then
link = PerfArray(iCtr) .strFund_Name & ".Doc"
else
link = PerfArray(iCtr) .strTicker & ".Doc"
end if
FollowHyperlink link
Is there a way that both buttons can point to the same sub or do I have to
have one of them point to its own sub and then call this one? 5 3255
Hi Alan,
Put the code you wrote straight into a sub of it's own with an input
parameter, then call the sub from the Click event of both buttons, passing a
different parameter.
e.g.
Private Sub Button1_Click()
SetLink("One")
End Sub
Private Sub Button2_Click()
SetLink("Two")
End Sub
Private Sub SetLink(pstrWhi chButton as String)
Select Case pstrWhichButton
Case "One"
link = PerfArray(iCtr) .strFund_Name & ".Doc"
Case "Two"
link = PerfArray(iCtr) .strTicker & ".Doc"
End Select
FollowHyperlink link
End Sub
You get the idea.
Anderw
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message
news:4Hy1c.1098 44$Xp.484367@at tbi_s54... I have a sub that can do two different tasks based on the value of one variable. So I'd like to have two different buttons on the same form run this, but each one setting a flag so that the conditional logic knows
which one to run.
Here is what I have in mind:
If Button_One_Was_ Pressed then link = PerfArray(iCtr) .strFund_Name & ".Doc" else link = PerfArray(iCtr) .strTicker & ".Doc" end if
FollowHyperlink link
Is there a way that both buttons can point to the same sub or do I have to have one of them point to its own sub and then call this one?
Thanks!
"Andrew" <an************ **@webster.org> wrote in message
news:V6******** **********@news-server.bigpond. net.au... Hi Alan,
Put the code you wrote straight into a sub of it's own with an input parameter, then call the sub from the Click event of both buttons, passing
a different parameter.
e.g. Private Sub Button1_Click() SetLink("One") End Sub
Private Sub Button2_Click() SetLink("Two") End Sub
Private Sub SetLink(pstrWhi chButton as String) Select Case pstrWhichButton Case "One" link = PerfArray(iCtr) .strFund_Name & ".Doc" Case "Two" link = PerfArray(iCtr) .strTicker & ".Doc" End Select FollowHyperlink link End Sub
You get the idea.
Anderw
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message news:4Hy1c.1098 44$Xp.484367@at tbi_s54... I have a sub that can do two different tasks based on the value of one variable. So I'd like to have two different buttons on the same form
run this, but each one setting a flag so that the conditional logic knows which one to run.
Here is what I have in mind:
If Button_One_Was_ Pressed then link = PerfArray(iCtr) .strFund_Name & ".Doc" else link = PerfArray(iCtr) .strTicker & ".Doc" end if
FollowHyperlink link
Is there a way that both buttons can point to the same sub or do I have
to have one of them point to its own sub and then call this one?
"Andrew" <an************ **@webster.org> wrote in message news:<V6******* ***********@new s-server.bigpond. net.au>... Hi Alan,
Put the code you wrote straight into a sub of it's own with an input parameter, then call the sub from the Click event of both buttons, passing a different parameter.
e.g. Private Sub Button1_Click() SetLink("One") End Sub
Private Sub Button2_Click() SetLink("Two") End Sub
Private Sub SetLink(pstrWhi chButton as String) Select Case pstrWhichButton Case "One" link = PerfArray(iCtr) .strFund_Name & ".Doc" Case "Two" link = PerfArray(iCtr) .strTicker & ".Doc" End Select FollowHyperlink link End Sub
You get the idea.
Anderw
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message news:4Hy1c.1098 44$Xp.484367@at tbi_s54... I have a sub that can do two different tasks based on the value of one variable. So I'd like to have two different buttons on the same form run this, but each one setting a flag so that the conditional logic knows which one to run.
Here is what I have in mind:
If Button_One_Was_ Pressed then link = PerfArray(iCtr) .strFund_Name & ".Doc" else link = PerfArray(iCtr) .strTicker & ".Doc" end if
FollowHyperlink link
Is there a way that both buttons can point to the same sub or do I have to have one of them point to its own sub and then call this one?
Hello all. I'm certainly missing something here and perhaps
it could be explained. Why so much about which button was
pressed? Can't you just put the code you want behind each
of the buttons separately? Example:
Private Sub Button1_Click()
link = PerfArray(iCtr) .strFund_Name & ".Doc"
End Sub
Private Sub Button2_Click()
link = PerfArray(iCtr) .strTicker & ".Doc"
End Sub
This seems to work for me and seems a bit simplier
to code.
Regards,
Ray
"Ray" <ra*****@excite .com> wrote in message
news:20******** *************** ***@posting.goo gle.com... Hello all. I'm certainly missing something here and perhaps it could be explained. Why so much about which button was pressed? Can't you just put the code you want behind each of the buttons separately? Example:
Private Sub Button1_Click() link = PerfArray(iCtr) .strFund_Name & ".Doc" End Sub
Private Sub Button2_Click() link = PerfArray(iCtr) .strTicker & ".Doc" End Sub
This seems to work for me and seems a bit simplier to code.
Regards,
Ray
Of course when the code is that simple, it doesn't make much difference.
But what if the code was supposed to do a million and one complicated
calculations, then create an Excel spreadsheet and save it in a location
specific to which button was pressed - and this time there were 5 different
buttons.
Would you write all of the code and copy it 5 times altering a small part of
the code specific to each button? What then when you adjust your code, each
time keep 5 separate versions updated? By writing the bulk of the code only
once you save duplication with all the bug-risks that introduces and make it
far easier to read and maintain.
Fletcher
"Fletcher Arnold" <fl****@home.co m> wrote in message
news:c2******** **@sparta.btint ernet.com... "Ray" <ra*****@excite .com> wrote in message news:20******** *************** ***@posting.goo gle.com... Hello all. I'm certainly missing something here and perhaps it could be explained. Why so much about which button was pressed? Can't you just put the code you want behind each of the buttons separately? Example:
Private Sub Button1_Click() link = PerfArray(iCtr) .strFund_Name & ".Doc" End Sub
Private Sub Button2_Click() link = PerfArray(iCtr) .strTicker & ".Doc" End Sub
This seems to work for me and seems a bit simplier to code.
Regards,
Ray Of course when the code is that simple, it doesn't make much difference. But what if the code was supposed to do a million and one complicated calculations, then create an Excel spreadsheet and save it in a location specific to which button was pressed - and this time there were 5
different buttons. Would you write all of the code and copy it 5 times altering a small part
of the code specific to each button? What then when you adjust your code,
each time keep 5 separate versions updated? By writing the bulk of the code
only once you save duplication with all the bug-risks that introduces and make
it far easier to read and maintain.
Exactly. I already have enough spagetti in this app and I do not need any
more. The sub was not yet debugged and was about 60 lines when I asked for
help. By having the flag set, I only had to have one copy of debugged code
in my app. If I discover a bug later on, I will only have to fix it in one
place. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JR |
last post by:
Hi. I have a CGI script that will need to call itself an unknown
number of times, to add rows, run queries, etc. At the bottom of the
output that is produced by the script, there are four buttons. I need
one of the buttons to simply be a back button. I have this button
working fine. I need the second and fourth buttons to point to the
current CGI script, but I need the third button to point to a
different CGI script. I need the...
|
by: Lyn |
last post by:
Hi,
I hope someone can help.
I have a main form which mostly fills the Access window. In the bottom half
of this form I have a tab control to display various types of data related
to the main form record. In each page of the tab control, there are three
buttons: Add, Update, Delete. Any of these buttons will open another,
smaller form to add, update or delete the related data record.
Originally, I had placed the smaller form such...
|
by: Axel |
last post by:
An Access 2000 question
Hi
is is possible to have (as a subform) a continous form with 0..n
buttons which have different images in each row.
(Personally I would have preferred a button array and assign images in
code, much easier with a class module - but unfortunately Access does
not support control arrays).
|
by: Girish |
last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as
<input type="image">.
I need to be able to eble the ENTER button for both buttons. Yes, I know
that for the input type image, the submit happens automatically to the
server. Heres my problem:
I have two event handlers for both these buttons as stated below:
BUTTON 1:
|
by: axlq |
last post by:
How do I create a form that two submit buttons, where each one
submits the form input data to a different server?
Consider this situation: I have a form where users can check various
options to subscribe to a service, and each option costs a certain
amount. When the form is submitted, my php script totals up the
options. Fine.
The form has 2 submit buttons: "print invoice" and "pay by credit
card."
| |
by: markroworth |
last post by:
Hi there,
I want to create a form with two buttons on that navigate to two different pages. The code I have at the moment looks like this:
<form action="login.php" method="post">
<table rows=2>
<tr>
<td><h5>Username</h5></td>
<td><input type="text" name="UID"/></td>
</tr>
|
by: Ryan Liu |
last post by:
Hi,
I have a big urgent problem to solve.
I used to use Windows 2000 Chinese version, now I installed Windows XP
(English) system.
The problem is not about 2000 or XP, it is about English and Chinese.
All forms of my compiled C# desktop application, as well as in Visual Studio
|
by: tarabztk |
last post by:
MSACCESS 2003 : How to use command buttons to display different subforms
I have an application that display information about Pipelines and these pipelines have many other equipments attached to them like ‘Valves’, ‘Tanks’, ‘Pumps’, etc.
In this application I display using Access form, all details about a selected Pipeline. And I included in this form, a sub-form which display valves information by default.
What I would like to do is...
|
by: Peter Oliphant |
last post by:
I'm developing a program at home on a Windows Vista computer. In it I create
a form with a few buttons on it that fill up the form's visible area.
So, I took the application to work, where I use a Windows XP PRO computer.
When I ran my program, the form visible area is different! Not very much,
but it is obvious. I haven't done experiments yet, but it looks like the
form is slightly wider and slightly shorter. I now have extra space on...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |