Recordset does not populate listbox - MS Access VBA

53 views Asked by At

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.

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.

1

There are 1 answers

1
Shahram Alemzadeh On BEST ANSWER

This is wrong:

Me.selListRS.RowSourceType = "Query/Table"

Edit it as following:

Me.selListRS.RowSourceType = "Table/Query"