MS Access Crashes on ListBox.addItem

ListBox 1

I had a problem in Access, that made havoc to old projects i had, as i have a form that i use a general utility in multiple .mdb programs.

and I have in them a ListBox, that gets filled by an array.

now the problem comes if i have an array of Strings, that have multiple or one of its items, not initialized, and then i try to add its content to the listbox, then MS Access crashes totally, without knowing what is the problem.

I had sometime before pinpointed the problematic line, and to understand the why.

to repeat the error, make a form, and add to it a listbox, and make its property “Row Source Type = Value List”

then add a button, and insert into its click event the following lines of code:

Private Sub btnAddItemsSame_Click()
On Error Resume Next
Dim arr(50) As String
Dim i As Integer

    For i = 0 To 10
        Me.lstBox.AddItem arr(i)

End Sub

also, made a test .mdb file for others to download.

user voice:


About Reader Man حسين ناجي الصفافير

حسين ناجي الصفافير Hussain Naji Al-Safafeer Info:
This entry was posted in Technical and tagged , , . Bookmark the permalink.

2 Responses to MS Access Crashes on ListBox.addItem

  1. Shane Groff says:

    What version of Access are you using? I can’t re-produce this problem.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s