Deleting text in Combobox to make value Null again

MCCDOM

Registered User.
Local time
Today, 21:12
Joined
Oct 30, 2014
Messages
84
Hi There,

I was wondering if it was possible whereby when you delete the selected text out of a combobox it returns the value of the combobox back to Null.

To put it in context, I have a form with a combobox which when the form is first loaded the combobox is empty (Null). Now if I choose a value from the drop down list of the combobox it is no longer of a Null value but if I was to scrub out the chosen value in the combobox would that return its value to Null?

Many Thanks,

Dom
 
Hi Minty,

Thanks for your reply. I don't want to reset the value back to Null via code. While on the form I would like to erase the text in the combobox and have an after update event that checks if the comboboxes value is Null and then i'm going to make a button visible based on if it is Null. At the moment the code I have doesn't recognise that I have erased the text from the combobox on the form.
Code:
If IsNull(cboOffice) Then
btnCreate.Visible = True
End If
 
That's because deleting the text leaves it as a zero length string (ZLS), which is NOT Null
Check for "" and Null in your code. There are at least a squillion ways to do this, and frankly I'm not sure what method is actually the "Best".

You can use the following which is quite neat and verbose
If Len(Me.cboOffice & "") <1 Then
or which is more obvious
If Me.cboOffice = "" or IsNull(Me.cboOffice) Then
 
...That's because deleting the text leaves it as a zero length string (ZLS), which is NOT Null...

Returns it to Null, for me, in v2007, whether you highlight and Delete it or Backspace to erase it!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom