Looking for help with a multi select list box query

Nightspawn

New member
Local time
Today, 11:32
Joined
May 10, 2007
Messages
3
Hi, I'm new to access so i'll be grateful for any help, hints or tips.

I'm having a bit of trouble querying data from a multi select listbox and i'm wondering if anyone has some tips on how to get around the problem.

The query I am trying to do is to select multiple postcode areas and query a customer table to list all the customers in the selected areas.

The form I made allows me to select multiple postcode areas, but when I press the Run Query button on the form I get a msgbox pop up asking me to 'enter parameter value' for each of the selected areas. If I input values in the msgbox - the query runs fine, but I would like it to use the values from the listbox and not need any further input.

I have attached a sample table and my form - incase anyone can shed some light on where I've gone wrong.

Thx for any help received
 

Attachments

Hello Nightspawn,

You forgot to add the mandatory single quotes for strings in your SQL query.
It should be WHERE [PCAREA]='AB', not WHERE [PCAREA]=AB.
Change the following line:
Code:
    strTempItem = strTempItem & " [PCAREA]=" & Me.ActiveControl.ItemData(varItem) & " Or "
to
Code:
    strTempItem = strTempItem & " [PCAREA]='" & Me.ActiveControl.ItemData(varItem) & "' Or "
 
Hi ErikSnoek,
Awesome!
Thanks a lot ~ works a treat now, your help was really appreciated :D
 

Users who are viewing this thread

Back
Top Bottom