Passing events between forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If I call a form as a result of selecting a menu option, is it possible for
the form to pick up on which option it was called from?

I have a form which can be used to enter data into 2 different tables
(Certificate and Category), and it has add/edit/delete buttons. I want the
form to be able to detect whether the user selected Certificate or Category
in the main menu, and alter the text on the buttons accordingly. I've worked
out a way to do it using a module to define a public variable; the variable
is set by the menu click events and the form can then test the variable and
set button text accordingly. It works, but I don't like it - I don't want to
use public variables, as you're supposed to keep everything as private as
possible. Is there an event raised which the form can detect in order to
determine which menu option as selected?
 
Thanks!

Actually, the solution was embarrassingly simple. The second form also has a
tab control for Category and Certificate; all I had to do was set
Form2.TabControl1.SelectedIndex to the appropriate value in the code segment
for each menu item, i.e.:

Sub MenuItem3_Click
Form 2.TabControl1.SelectedIndex = 0
Form2.ShowDialog()
End Sub

etc. Form2 can then determine in code which tab is selected, and alter
button text accordingly. I knew there had to be SOME way to do it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top