ListBox Problem

P

PatK

Can anyone tell me what is wrong with this event code in my form class
module? Gotta be something obvious. While the form is open (so thus, I
believe it must be getting to this event), I do not see the message box, nor
do I see the list populated. Note that WSNames is a public string, and right
before I open this form, I debug.print it, and see the contents of my list
just fine, in the debug, ie:
Listitem1;listitem2;etc;

I am new to theses forms, and listboxes, so I presume it is something dumb
(note: the listbox is named lstAvailable)...

Thanks, Patk

Private Sub Form_Open(Cancel As Integer)
MsgBox "I made it to Form_Open"
lstAvailable.RowSourceType = "Value List"
lstAvailable.RowSource = WSNames

End Sub
 
M

Marshall Barton

PatK said:
Can anyone tell me what is wrong with this event code in my form class
module? Gotta be something obvious. While the form is open (so thus, I
believe it must be getting to this event), I do not see the message box, nor
do I see the list populated. Note that WSNames is a public string, and right
before I open this form, I debug.print it, and see the contents of my list
just fine, in the debug, ie:
Listitem1;listitem2;etc;

I am new to theses forms, and listboxes, so I presume it is something dumb
(note: the listbox is named lstAvailable)...

Private Sub Form_Open(Cancel As Integer)
MsgBox "I made it to Form_Open"
lstAvailable.RowSourceType = "Value List"
lstAvailable.RowSource = WSNames

End Sub


If you are not seeing the message, then the event procedure
is probably not being called. Double check the to form's
OnOpen property contains:
[Event Procedure]
 
G

gllincoln

Hi Pat,

In spite of what you believe - the event is probably not happening. In
Access 2007, security level, ie your code being disabled, can be an easily
overlooked factor.

As Marshall said - You also might want to open the form in design mode, look
at the form property sheet on open event, see if 'procedure' shows up as a
known property.

Gordon
 
P

PatK

I have come to the same conclusion as well. When I click on the "On Open"
property field, (the "...") it takes me right to this code. And clearly, the
form "is" opening. I guess I wonder what "on open" means and when the event
is actually triggered to occur.

The form is a "modal" form intended as a pop-up. Not sure if that changes
anything? I have DoCmd.OpenForm "formname" statement in a vba module (not
in a form class) that is to pop open the form. I have gotten various strange
errors on that when I have played with various parameters. Currently, the
error I get is on the do.cmd.openform is:

Run-time Error '2501': The OpenForm Action was canceled.

And of course, that is "exceptionally" useful as it says what happened, but
no reason as to why (like, is it the "on open" code that is causing
this...not much there, except the msgbox and debugs, with the exception of
the code I submitted above). The do.cmd looks like this:

DoCmd.OpenForm "Import Excel Worksheet"

That form is the form the listboxes are in.

Thanks for any further help/insights....

Patk
 
P

PatK

I found one of Allen Browne's posts about the error I was getting, so I ran
debug/compile, as was suggested. It found a couple things, that "seem" to be
unrelated to the problem I was having, but I fixed them nontheless, and lo,
it started working. This is truly FM sometimes.

Thanks for all the help, tho...I have learned a lot from all of you! (and
will, I hope in the future!)
 

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