Deselecting items in a listbox

  • Thread starter Thread starter Chad Cameron
  • Start date Start date
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
 
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
 
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)
 
Back
Top