You would have saved yourself a heap of bother if you'd read Help or any of
a squillion web tutorials on variable scoping in VB/VBA.
As a quick fix, put 'Option Explicit' at the top of your form (and every
other) code module. Then you would have got compiler errors as soon as you
tried to run your form, which would also have alerted you to the problem.
In short, variables declared within a function (such as those you declare in
Initialize) are valid ONLY WITHIN THAT FUNCTION. If you want module-level
variables, you need to declare them at the start of the module, outside any
function.
Separately, your declarations are not doing what you intend --
> Dim x, xval As Integer
> Dim xbatch, xweek, xdow As String
The 'as' part applies only to the last variable in each case. As it stands,
you are declaring x, xbatch, and xweek as variants.
And it is more efficient to use Longs than Integers. Integers are provided
only for backward compatability.
>I have created a userform containing 1 textbox, 2 comboboxes, and 1
> commandbutton.
[quoted text clipped - 64 lines]
>
> End Sub
Craig - 20 Dec 2006 06:05 GMT
Thanks. I'll look that up and give it a try. This is the first time I've
written any code since 1990 and the last thing I wrote was in Pascal. I do
have a degree in computer programing, but I've never written anything or even
looked at VBA until now, and the only reason I'm doing it now is I'm the most
experienced in my department....lol
> You would have saved yourself a heap of bother if you'd read Help or any of
> a squillion web tutorials on variable scoping in VB/VBA.
[quoted text clipped - 87 lines]
> >
> > End Sub
Jezebel - 20 Dec 2006 06:49 GMT
Pascal had scoping and declaration rules, too, if my recollections of
antedeluvian programming are still valid ...
> Thanks. I'll look that up and give it a try. This is the first time I've
> written any code since 1990 and the last thing I wrote was in Pascal. I
[quoted text clipped - 105 lines]
>> >
>> > End Sub
Doug Robbins - Word MVP - 20 Dec 2006 08:46 GMT
Please do not post the same question separately to multiple newsgroups. I
now see that I have spent time answering your question in the
microsoft.public.word.vba.userforms newsgroup only to find the same question
here has already been answered.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Thanks. I'll look that up and give it a try. This is the first time I've
> written any code since 1990 and the last thing I wrote was in Pascal. I
[quoted text clipped - 105 lines]
>> >
>> > End Sub