Setting Default values for a ListBox with a query as a row source

timkeats

New member
Local time
Tomorrow, 04:30
Joined
Jun 8, 2007
Messages
8
The Microsoft help page says that this should work:

[lstStatus].[ItemData](2)

in the Default Value property to set a single value as a default, but it doesn't.

How do i set multiple items as the default in a ListBox?

Thanks anyone
 
Try...
Code:
=lstStatus.ItemData(2)
Selecting multiple items by default requires that you know what items in advance, loop thru the items, find them in the list, and select each one.
How are your coding skills?
 
Setting default values for ListBox

Thanks, I had tried this but Access adds in the square brackets.

For multiple values, i imagine the setting would have to be separated by " OR ", is that right?

This seems a pretty ugly method, there must be a more elegant solution?

Try...
Code:
=lstStatus.ItemData(2)
Selecting multiple items by default requires that you know what items in advance, loop thru the items, find them in the list, and select each one.
How are your coding skills?
 
I don't think you can set multiple defaults for a listbox. You would need to set the selection via code in the On Current event.
 
- For a single default similar to what you first posted you need an equals sign
Code:
=lstStatus.ItemData(0)
- The square brackets are irrelevant and I removed them for clarity, but this solution presumes that the MultiSelect property of the list is set to None. This approach will fail if the list's MultiSelect property is set to Simple or Extended.
- If MultiSelect is Simple or Extended the .Value property of the control is meaningless so you can't simply assign a value to create a selection.
- If your list is MultiSelect I believe you need to implement a default value, either single or multiple, by writing moderately difficult code.
 

Users who are viewing this thread

Back
Top Bottom