By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,956 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,956 IT Pros & Developers. It's quick & easy.

Create ListBox programatically

P: 10
Hi Guys,

is it possible to create an instance of ListBox programatically?
Actually I have two issues here:

1.)
When I type this line in Access 2003:
Expand|Select|Wrap|Line Numbers
  1. Dim tmpList As ListBox
  2. Set tmpList = New ListBox
Access' run-time compiler changes the "ListBox" name to "listbox" (lowercase):
Expand|Select|Wrap|Line Numbers
  1. Dim tmpList As listbox
  2. Set tmpList = New listbox
2.)
When the second line is executed the tmpList remains set to "nothing".

What am I doing wrong?
Thanks a lot.
juing
May 6 '09 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,679
@juing
To the best of my knowledge the The New keyword can't be used to declare instances of dependent Objects. What exactly are you trying to accomplish?
May 6 '09 #2

P: 10
@ADezii
I want to create instance of the ListBox class for temporary purposes.
What are dependent Objects ?

I temporarily solved this by adding ListBox component to one of my forms and made it invisible. And I use its object as a temporary listbox for storing data.
May 6 '09 #3

ADezii
Expert 5K+
P: 8,679
@juing
I want to create instance of the ListBox class for temporary purposes.
What are dependent Objects ?
In the case of a ListBox, it is essentially dependent of the Form on which it is contained. I'm referring to a Parent Object.

P.S. - You can also create a ListBox programmatically via the CreateControl() Method. This will basically be a New ListBox altogether and not a New Instance of the ListBox Class.
May 6 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.