Invalid Outside Procedures

F

Fran

Hi people

I've just tried to run the following code

Private Sub_Form_Load()
With lstMonth
..AddItem "January"
..AddItem "February"
..AddItem "March"
..AddItem "April"
..AddItem "May"
..AddItem "June"
..AddItem "July"
..AddItem "August"
..AddItem "September"
..AddItem "October"
..AddItem "November"
..AddItem "December"
End With
End Sub

In an attempt to add items to a list box named "lstMonth".

When I try to run the procedure, I get "invalid outside procedure" as
the message. Can anyone suggest what I'm doing wrong, or is this some
sort of strange run time error?

The curious thing is that when I ran a test as follows:

Private Sub_Form_Load()

lstNames.AddItem "Joe Bloggs"

End Sub

for a list box named "lstNames" it works fine.

Any ideas what is going on?

Fran
 
D

Doug Robbins - Word MVP

I am assuming that this is a form in Access (it is definitely not Word,
which is the focus of this newsgroup)

However, I cannot replicate the problem when using code in that event of an
Access Form.

The error message would indicate that you have something outside of a Sub -
End Sub routine.

--
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
 
H

Helmut Weber

Hi Fran,

not
Private Sub_Form_Load()
but
Private Sub Form_Load()

Do you see the difference?
Private Sub_Form_Load()
lstNames.AddItem "Joe Bloggs"
End Sub

for a list box named "lstNames" it works fine.

I doubt it, seems impossible to me.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
F

Fran

I am assuming that this is a form in Access (it is definitely not Word,
which is the focus of this newsgroup)

However, I cannot replicate the problem when using code in that event of an
Access Form.

The error message would indicate that you have something outside of a Sub-
End Sub routine.

--
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

My apologies ... I thought this was a group for Visual Basic 6 --

mea culpa ...

Fran
 

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

Top