Using MS Access/Form Based Parameter Query - does not pull values
I am an advanced Access user and I am having trouble with a form based parameter query.
I have a form (frmSelectRecords) that simply has a list box (pulling "firm name" from my table) and a button. (The user can select more than one record)
I have a query (qryBalanceDifference) that is supposed to search the form for the paramters defined in the list box.
The criteria on firm name in my query reads: [Forms]![Select Records Form]![FirmName]
I have tried two different approches to the button. I have created a button from the wizard using the "Run Query" function.
I have also tried creating a button with the following code tied to the ON Click event:
Private Sub OK_Click()
Me.Visible = False
DoCmd.OpenQuery "qryBalance Difference", acViewNormal, acEdit
DoCmd.Close acForm, "frmSelectRecords"
Both of these options return the same result: The query runs and the form closes, but the query doesn not populate with the records I selected in the list box.
Any ideas/tips??? Any help would be very much appreciated! Thanks!
First you've got some naming discrepancies there. You said the form is frmSelectRecords but your code is looking at [Forms]![Select Records Form]![FirmName] which is not right.
Next, if you're using a listbox with a SINGLE RECORD, then this should work just fine, however when you start dealing with multi-select listboxes you can't just pick more than one item and expect it to work. There's a whole bunch of VBA needed to parse the values. I cover this in detail in my Access 321
tutorial. It's far too complex to go into here.