Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Recordset does not populate listbox – MS Access VBA

I’m trying to populate a listbox in a form using VBA in MS Access.
I’ve done this multiple times before and never had an issue but now the listbox does not get populated.

Here is my code:

Private Sub Form_Load()
    linkedOrders = linkedOrderList

    qGetLinks = "SELECT *Various fields from table* FROM *Table* WHERE *Conditioned_field* IN(" & linkedOrders & ")"
    Set rsLinks = CurrentDb.OpenRecordset(qGetLinks, dbOpenDynaset, dbSeeChanges)

    Me.selListRS.RowSourceType = "Query/Table"
    Me.selListRS.RowSource = ""

    Set Me.selListRS.Recordset = rsLinks
End Sub

Please note that ‘linkedOrderList’ is a Global variable that is populated correctly upon loading the form.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’ve tried googling the issue but since I’m using the exact same code (save for variable names) as I always do I cant seem to find any solutions and I’m nearing my wit’s end.

I’ve ran the code using breakpoints to make sure that all variables and recordsets gets populated as expected and found no issues there.
The RS ‘rsLinks’ gets the expected result from my SQL-query, so no beef there either.

I’ve checked all my spellings a few times but as far as I can see, all is gravy there.

>Solution :

This is wrong:

Me.selListRS.RowSourceType = "Query/Table"

Edit it as following:

Me.selListRS.RowSourceType = "Table/Query"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading