Solved

userform needs a subform

Posted on 2011-02-23
8
473 Views
Last Modified: 2012-05-11
excel 2003 vba
access 2003

 What I have:
A userform but trying to display items being rectrned in a recordset(from access) like a subform. On my userform.

What I need for now...
I have a listbox to hold my records in the return recordset.
However it is not displaying them properly. Like a list...
they are just on one single line.

'Create a Snapshot Type Recordset from the SQL query
Set rstFromQuery = dbsEAIQuote.OpenRecordset(strSQL, dbOpenSnapshot)


'Move to the last record in the recordset
rstFromQuery.MoveLast

With frmiCart.ListBox1
    .ColumnCount = rstFromQuery.Fields.Count
          .Column = rstFromQuery.GetRows(rstFromQuery.RecordCount)
End With


Maybe the listbox is the only way to create a subform in excel ?

anyway I need all records to show as a list in listbox1 ?

Thanks
fordraiders






 
0
Comment
Question by:fordraiders
  • 4
  • 4
8 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34965788
Use:
 .List= Application.Transpose(rstFromQuery.GetRows())

Open in new window

0
 
LVL 3

Author Comment

by:fordraiders
ID: 34966520
not working...error
With frmiCart.ListBox1
 
    .ColumnCount = rstFromQuery.Fields.Count
          .Column = rstFromQuery.GetRows(rstFromQuery.RecordCount)
.List = Application.Transpose(rstFromQuery.GetRows())   <------  "no  current record"

End With
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34967923
I meant use that instead of your .column =... line
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34969863
rorya, I did.
STILL ERROR 3021    no current record...

this way:
With frmiCart.ListBox1
     .ColumnCount = rstFromQuery.Fields.Count
 .List = Application.Transpose(rstFromQuery.GetRows())
End With

this way:
With frmiCart.ListBox1
     .List = Application.Transpose(rstFromQuery.GetRows())
End With



0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34969869
You probably need to MoveFirst before you use GetRows.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 35036869
ok tried that...  rorya..not working
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 35036922
Hmm, maybe DAO requires the number of rows to retrieve:
With frmiCart.ListBox1
     .ColumnCount = rstFromQuery.Fields.Count
 .List = Application.Transpose(rstFromQuery.GetRows(rstFromQuery.Recordcount))
End With

Open in new window


If that still doesn't work, can I see the full code, please?
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 35112345
ok thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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,…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now