Multiselect property

R2D2

Registered User.
Local time
Today, 03:25
Joined
Jul 11, 2002
Messages
62
I'd like to change the multiselect property of a listbox using code when the user clicks a button. VBA help lists a way of doing this:

Forms("Order Entry").Controls("Country").MultiSelect = 2

However, this doesn't work. My code won't even run when this line is in there. When I comment it out, the code does run....so clearly, this line is the problem. Any ideas?
 
Hi,

Gives it an error when the code not runs?

Try this:
Forms![Order entry]!Country.MultiSelect = 2
 
No, it doesn't give an error - it just simply won't run. I've had an ongoing problem with Access making buttons, functions, etc. simply not run rather than giving me an error. I haven't been able to figure out why yet.

I've already tried using different syntax to refer to my listbox:

Me.lstFOAP.MultiSelect = 0

(Note - the line of code I gave in my original post came from the microsoft help and didn't reflect the proper names of my forms and controls...when I tried it, I switched the names for my own, but when I posted I copied the line directly from help without changing them).

And it still doesn't work.
 
Oh, now I read the help for this topic.

This property can only be changed in designmode of the form...

Code:
DoCmd.OpenForm "MyForm", acDesign
Forms!MyForm!lstFOAP.MultiSelect = 2
DoCmd.OpenForm "MyForm", acNormal
 
Ok, I tried that as well....but for some reason code execution stops after it goes to design mode...is code not able to run on a form when it's in design mode?

Thanks for trying to help....I really appreciate it.
 
No, you can run it from a module. Put it in a public sub or function and call that from your forms' code
 

Users who are viewing this thread

Back
Top Bottom