Access of Listbox contents in OnOpen gines Null

D

David

I load a listbox in the OnOpen event and also sometimes need to access its contents (its a Valuelist). I can load the listbox, but when I refer to Me!LB.Column(0), its a Null. It seems I can't refer to the contents until the form is displayed, since it works fine in the OnClick event. Any way around this?
 
A

Albert D. Kallal

You can usually read the values of controls in the on-open event, but you
CAN NOT modify values.

The on-open event of a form has a "cancel" feature, and if you set cancel =
true, then the form does not load.

So, on-open, is really for checking values, and things that *could* allow
you to change your mind if the form is to be opened (for, example, if the
record is locked by somene else..you could display a message..and the form
would NOT load).

So, once your checking/testing code to allow the form to open is completed,
then any code that sets up the forms values, defaults and initialize your
variables etc belongs in the forms on-load event..NOT the on open. On open
is too soon to start playing with, and modifying values..and further..the
on-open event is not for setup and initializing code anyway.

So...move your code stuff to on-load.....
 

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