|
-
Feb 4th, 2000, 02:23 AM
#1
Thread Starter
Frenzied Member
Here is another way to implement netSurfer's first idea, only instead of using a global variable, use the Save button's Tag property.
I have found the Tag property to be very useful (especially in control arrays where all controls have the same name and are only differentiated by an index).
Simply set the Tag property (which is a string) of the Save button to the caption of the last button clicked. Do this under the click event of the NewRecord button and the Changes button.
Here's an example:
Code:
Option Explicit
Private Sub Form_Load()
'Make sure tag is empty when form loads
cmdSave.Tag = ""
End Sub
Private Sub cmdChanges_Click()
cmdSave.Tag = "Changes"
End Sub
Private Sub cmdNewRecord_Click()
cmdSave.Tag = "NewRecord"
End Sub
Private Sub cmdSave_Click()
If cmdSave.Tag = "Changes" Then
'Put code here that reflects that user
'clicked the "Change" button
ElseIf cmdSave.Tag = "NewRecord" Then
'Put code here that reflects that user
'clicked the "New Record" button
Else
'Put code here that reflects that user
'didn't click either button first
End If
End Sub
Hope that helps!
~seaweed
-
Feb 4th, 2000, 12:42 PM
#2
Lively Member
Hi, everybody!
Is there a way I can use to find out what of two buttons was the last one to be clicked?
I've got a button for "Changes" and a button for "New record" and I'd like my button "Save" to act with some little differences, deppends on the button clicked before.
Any ideas on how to control this?
Thanks in advance,
Roselene
-
Feb 4th, 2000, 12:51 PM
#3
Hyperactive Member
quick way:
dim strBtn as string
in the General Declarations of your form
whne click changed button:
strBtn = "Changed"
when New
strBtn = "New"
for the Saved button:
if strBtn = "Changed" then
elseif strBtn = "New"
Or you could change the caption on the button. When they change a record, you're actually opdating it so changethe Caption to "Update" then in the Saved button's Click event do:
if cmdSaved.caption = "Update" then
'do changed routine
else
'do new routine.
end if
Either way would work.
------------------
----------------------
I'm really easy to get along with once you people learn to
worship me.
----------------------
-
Feb 6th, 2000, 06:43 PM
#4
Lively Member
Seaweed,
Thanks for taking the time for helping me.
I'll give it a try!
See you,
Roselene
-
Feb 6th, 2000, 08:40 PM
#5
Hyperactive Member
You can also use a boolean, if it's only to detect if you need to add a new record or not
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|