Can't set value of a list box to null

G

Guest

I have a macro using Setvalue to set the value of several contols in a form
to null. One of the contols I'd like to set the value to null is a list box.
When the same control was a text box the setvalue worked fine. But when I
change it to a listbox, the setvalue doesn't work. How can I set the value
of my list box to null. I've also tried: Me.Ref_Part_Supplier_Name = Null in
an AfterUpdate of another control and that doesn't work either. The name of
my control is Ref Part Supplier Name. I know I shouldn't have put spaces in
the name, but it's too late to turn back now. I'm using the control name in
other code as well. Thanks

alex
 
A

Allen Browne

If this is a multi-select list box, you cannot just set it to Null.

If it is not, the code you have should work, or you could use square
brackets around the name:
Me.[Ref Part Supplier Name] = Null
 
G

Guest

Not a multi list and the code doesn't work with or without the brackets.
There must be something else going on - frustrating. Thanks for your help
Allen; I'll figure it out.

Alex

Allen Browne said:
If this is a multi-select list box, you cannot just set it to Null.

If it is not, the code you have should work, or you could use square
brackets around the name:
Me.[Ref Part Supplier Name] = Null
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Alex said:
I have a macro using Setvalue to set the value of several contols in a form
to null. One of the contols I'd like to set the value to null is a list
box.
When the same control was a text box the setvalue worked fine. But when I
change it to a listbox, the setvalue doesn't work. How can I set the
value
of my list box to null. I've also tried: Me.Ref_Part_Supplier_Name = Null
in
an AfterUpdate of another control and that doesn't work either. The name
of
my control is Ref Part Supplier Name. I know I shouldn't have put spaces
in
the name, but it's too late to turn back now. I'm using the control name
in
other code as well. Thanks

alex
 
J

John Vinson

Not a multi list and the code doesn't work with or without the brackets.
There must be something else going on - frustrating. Thanks for your help
Allen; I'll figure it out.

If the name of the control contains blanks then you MUST - no option,
no choice - enclose the name in square brackets. Underscore characters
are *not* a substitute for blanks and will not be recognized (even
though Access makes that substitution when it creates procedure names,
that's the *only* place it does so).

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top