Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Knowing witch button was pressed

Status
Not open for further replies.

davidmcolaco

Technical User
Aug 1, 2005
102
PT
Hi,

I have several forms with buttons that redirect to another form.
Is there a way to know witch button was pressed at last so I can know from witch form was redirected.

Thanks
 
I notice that you've asked over 40 questions, but haven't acknowledged any of the answers given. If the answers you got weren't helpful, read faq222-2244 to see how to ask better questions. If they were helpful, read faq222-2244 to see how to acknowledge them!

There are many possibles answers to this question, but the simple method is to use a Public variable

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
johnwm said:
If they were helpful, read FAQ222-2244 to see how to acknowledge them!
Look at paragraphs 15 and 16

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
There is a strange thing happening.
I defined a variable called Botao as public and then when I click a button I give her the value 1 and then redirect to another form. But when I arrive the other form, he already lost the value, because I use a msgbox to check and it's without value.

What's the problem of it?

Thanks.
 
Have you tried to define the public variable in a module?
 
If declare a global variable in a module. g_Button. Then when each button is pressed assign the variable a value. Should be that simple.
 
You might want to set a "break when value changes" watch for your global variable. You may find that you're actually changing it in an event that you don't realize is firing.

HTH

Bob
 
It's done. It's already working fine. Thanks for the help.
 
I know you have it working, but did you try this:

Private Sub Command1_Click()
Call WhatWasPressed(Me)
End Sub

Public Sub WhatWasPressed(MyForm As Form)

MsgBox MyForm.Name & " - " & MyForm.ActiveControl.Caption & " - " & MyForm.ActiveControl.Name

End Sub


---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top