Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open Userform two ways
I've a userform that needs to be loaded in one of two scenarios ...
First, it may be used to MODIFY an existing entry ... so would be pre- loaded using data passed from another userform. Or, it could be used ADD a new entry ... so would be loaded with all fields blank. How do I tell the userform which way to load? I could test to see if the other userform is loaded, but doing so would automatically load it anyway, right? Thoughts or ideas? TIA, Ray |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open Userform two ways
One way is to create a public variable in a General module.
Set that as an indicator of what should be done. Then use that indicator variable in the userform_initialize procedure. option explicit Public OpenFormModify as boolean Sub ShowMyForm() if something is true then openformmodify = true else openformmodify = false end if End sub And behind the userform: Option Explicit Private Sub UserForm_Initialize() if openformmodify = true then 'initialize the form with a record else 'initialize the form to add end if End Sub Ray wrote: I've a userform that needs to be loaded in one of two scenarios ... First, it may be used to MODIFY an existing entry ... so would be pre- loaded using data passed from another userform. Or, it could be used ADD a new entry ... so would be loaded with all fields blank. How do I tell the userform which way to load? I could test to see if the other userform is loaded, but doing so would automatically load it anyway, right? Thoughts or ideas? TIA, Ray -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open Userform two ways
Perfect! Thanks Dave ...
|
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open Userform two ways
And if the number of choices is more than 2 (so you can't use boolean), you can
declare it as string or long or whatever and check that in the _initialize event. Dave Peterson wrote: One way is to create a public variable in a General module. Set that as an indicator of what should be done. Then use that indicator variable in the userform_initialize procedure. option explicit Public OpenFormModify as boolean Sub ShowMyForm() if something is true then openformmodify = true else openformmodify = false end if End sub And behind the userform: Option Explicit Private Sub UserForm_Initialize() if openformmodify = true then 'initialize the form with a record else 'initialize the form to add end if End Sub Ray wrote: I've a userform that needs to be loaded in one of two scenarios ... First, it may be used to MODIFY an existing entry ... so would be pre- loaded using data passed from another userform. Or, it could be used ADD a new entry ... so would be loaded with all fields blank. How do I tell the userform which way to load? I could test to see if the other userform is loaded, but doing so would automatically load it anyway, right? Thoughts or ideas? TIA, Ray -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do you make a userform open automatically when you open excel? | Excel Worksheet Functions | |||
The error of my ways. | Excel Discussion (Misc queries) | |||
256 ways to make hamburger | Excel Worksheet Functions | |||
Ways to activate a macro | Excel Discussion (Misc queries) |