Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

listbox not populating all fields

Posted on 2013-10-30
9
Medium Priority
?
282 Views
Last Modified: 2013-10-30
vba 2010 excel

I'am populating a listbox via an array:
Arr = objMyRecordset.GetRows
       objMyRecordset.MoveFirst

With UserForm2.ListBox1
.Clear
.Column = Arr
.ColumnCount = 36
'.RowSource = Arr
        .ListIndex = -1
End With


I'AM not getting all the columns to show in the listbox?

so i tried setting the rowsource to "Arr"

But keep getting errors .?


Thanksd
fordraiders
0
Comment
Question by:Fordraiders
  • 5
  • 4
9 Comments
 
LVL 35

Expert Comment

by:Norie
ID: 39612058
Try using List and transposing the array.
With UserForm2.ListBox1
    .ColumnCount = objMyRecordset.Fields.Count
    .List = Application.Transpose(Arr)
End With

Open in new window

0
 
LVL 3

Author Comment

by:Fordraiders
ID: 39612373
.List = Application.Transpose(Arr)    error on this line <-----------
0
 
LVL 35

Expert Comment

by:Norie
ID: 39612381
Any particular error?

Does your recordset have any null fields?

How many records are in it?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:Fordraiders
ID: 39612454
error 13 typemismatch..
Does your recordset have any null fields?

"yes"

it varys...after each executing  request
0
 
LVL 3

Author Comment

by:Fordraiders
ID: 39612470
I'am using a temp variable to see if the arr is getting this value .
Dim strb As String

strb = objMyRecordset.Fields(15)
strb = strb

and it clearly is...
but once the array is populated it does not show in the listbox ?
0
 
LVL 35

Accepted Solution

by:
Norie earned 2000 total points
ID: 39612484
I think the problem might be the nulls.

Try rewriting your query so that they are replaced with blanks, or whatever is appropriate.
0
 
LVL 3

Author Comment

by:Fordraiders
ID: 39612493
weird because i have other places in the data where the fields are null?
0
 
LVL 35

Expert Comment

by:Norie
ID: 39612550
Do you mean other places where you are populating listboxes with arrays that have null values?
0
 
LVL 3

Author Closing Comment

by:Fordraiders
ID: 39612680
Thanks, got me on the right track !
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question