Solved

listbox not populating all fields

Posted on 2013-10-30
9
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 34

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 34

Expert Comment

by:Norie
ID: 39612381
Any particular error?

Does your recordset have any null fields?

How many records are in it?
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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 34

Accepted Solution

by:
Norie earned 500 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 34

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

751 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