I've created a query in Access 2013 that takes two parameters
PARAMETERS blah TYPE, blah TYPE;
SELECT * FROM blah WHERE blah blah;
I want to run that query and display the result in a listbox.
Normally I would do like
Me.MyListBox.RowSource = "myQuery"
But when I do so, a box is popping up telling me to enter the first parameter. How can I specify the parameters programatically?
My second approach was something like
With CurrentDb.QueryDefs("myQuery")
.Parameters("param1") = 1
.Parameters("param2") = 2
Me.MyListBox.RowSource = .OpenRecordset()
End With
That gave me type mismatch?
How can I do this?
EDIT: To make things clear, I know that I can concatenate strings to build the query I want, something like:
Me.MyListBox.RowSource = "SELECT * FROM table WHERE abc Like '" & somevalue & "'"
But this is precisely what I want to avoid because it makes the code difficult to maintain and read.