Thanks for the feedback, Jean-Guy. I think I see what you're driving at, but
it's really a case of 'six of one/half dozen of the other', isn't it? Either
the 'OK' button sets a flag itself or it calls the data collection module
that sets a flag. Unless I'm missing something, which is entirely possible, I
don't see much difference between the two. However, I do see a few small
advantages with calling a separate procedure (forgive me for calling it a
'module' in my previous post - just a slip of the keyboard):
First, I find it easier to keep track of what's being collected from the
UserForm if the collection process is in its own separate space rather than
embedded in the code that is primarily devoted to the loading and display of
the UserForm. If I miss a value or something goes wonky, this method makes it
simple to find where to look; just insert a break point at the start of the
procedure.
In addition, I see the collected data as be more document-related and
secondary to the UserForm itself. Therefore, the separate procedure is in
keeping with my rule that says, 'Don't mix your drinks!' ;-D Procedures
should be based around the objects and processes they're intended to support
- rather like your rule of keeping the code in the UserForm to only what is
required to support the form, altho at a bit finer granularity.
Finally, I don't have to worry about 'transporting variables across state
lines'. The bAddEnvelope flag is declared in the main module, initialised and
set in the main module, and evaluated and acted on in the main module. No
public global variables to try and track between modules; the only thing that
crosses between them are the values from the controls on the UserForm (which
are much more 'visible' than variables).
However, there may be advantages to your method that I'm just not seeing. If
so, please let me know as I'm always eager to learn. And I may give your
suggestion a go just for the experience of working with passing variables
between modules.
Thanks again for all your help. I really appreciate it.
--
Cheers!
The Kiwi Koder
"Jean-Guy Marcil" wrote:
[Several lines deleted for ease of readability]
>
> Glad to see that you sorted it out...
> Just a quick comment on your code.. You do not need a separate module to
> collect the info...
*** KK: Sorry, should have said 'procedure', not 'module'. ***
>
> For example:
>
> Private Sub AddEnvelope()
>
> Dim frmMyForm As frmEnvelopeDetails
> Dim boolGoAhead As Boolean
>
> 'This could be a public global variable in the Userform module _
> set it to false in the Initialize event, then if OK is clicked, set it
> to true
> 'bAddEnvelope = False
>
> boolGoAhead = False
>
> Set frmMyForm = New frmEnvelopeDetails
>
> With frmMyForm
> .Show
> boolGoAhead = .bAddEnvelope
> If boolGoAhead Then
> RecipName = .txtRecipientName
> RecipAddressL1 = .txtRecipientAddressL1
> RecipAddressL2 = .txtRecipientAddressL2
> RecipSuburb = .txtRecipientSuburb
> RecipCity = .txtRecipientCity
> RecipPostCode = .txtRecipientPostCode
> RecipAttention = .txtRecipientAttention
> End If
> End With
>
> Unload frmMyForm
> Set frmMyForm = Nothing
>
> If boolGoAhead Then CreateEnvelope
> Tools.SetToolbar
>
> End Sub
>