Deselecting items in a listbox

C

Chad Cameron

Hi All (again),

My combobox filters the listbox. If nothing is selected in the listbox,
then I have a bunch of fields that are locked. When the user selects an
item in the listbox, everythying is unlocked (obviously). Now, if the user
selects a different item in my combobox, a new set of names are available in
the listbox (but I think the item is still selected even though I cannot see
it). So I set my listbox to Null (non-multiselect). In VBA the popup hint
says lbContractorName = Null, but in the following code "If
Me.lbContractorName = Null Then" it doesn't register.

Any ideas why?

Thanks
Chad
 
D

Dirk Goldgar

Chad Cameron said:
Hi All (again),

My combobox filters the listbox. If nothing is selected in the listbox,
then I have a bunch of fields that are locked. When the user selects an
item in the listbox, everythying is unlocked (obviously). Now, if the user
selects a different item in my combobox, a new set of names are available
in the listbox (but I think the item is still selected even though I
cannot see it). So I set my listbox to Null (non-multiselect). In VBA
the popup hint says lbContractorName = Null, but in the following code "If
Me.lbContractorName = Null Then" it doesn't register.

Any ideas why?


Because by definition, nothing is ever equal to Null. Even the comparison,
Null = Null, returns Null -- neither True nor False. Use the IsNull()
function instead:

If IsNull(Me.lbContractorName) Then
' ...
End If
 
C

Chad Cameron

Works Great,

Thank you very much,
Chad


Dirk Goldgar said:
Because by definition, nothing is ever equal to Null. Even the
comparison, Null = Null, returns Null -- neither True nor False. Use the
IsNull() function instead:

If IsNull(Me.lbContractorName) Then
' ...
End If


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

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