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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Abstracting a form from its action 1

Status
Not open for further replies.

Spon349

Technical User
Apr 24, 2001
3
GB
How do you abstract a form from a task which it executes?

I have a simple form which allows ths user to select a month from a drop-down box, and then click either OK to bring about an action based on that selection, or Cancel. This works fine if I use it for one specific task, e.g. setting worksheet headers to the month that the user chose.

However, I want to use the same form in several (different) situations and can't find a way of abstracting the task from the form. Rather than having the "stuff to be done" in the
Code:
_Click()
event of the OK button, I want to return the fact that the user clicked OK and have the task's code elsewhere. I've tried declaring a public boolean in the form's code, setting it according to which button was clicked, and then referencing it from another module, but this doesn't work.

Any help would be greatly appreciated. I hope I've been clear enough!

Thanks
 
Using same form for different tasks:

1. Have two buttons on the form but make only one visible at a time.

2. Depending on the situation have a different caption on the button, then look at this to decide what to do.

eg. Have a button that changes caption from "Edit" to "Add" depending on which one you are doing. Then when the button is Clicked check the caption in an IF statement.

IF CmdButton.Caption = "Edit" Then
Call SubEdit
Else
Call SubAdd
End If

There are probably other ways to do this, but that is how I do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top