Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access List Box value capture

Status
Not open for further replies.

gareth001

Technical User
Feb 4, 2003
43
GB
Hi,

I've been trying to set a on Change command for a group of List boxes to enable a button when they contain data, but I can't seem to detect when they contain a null value. The code is as follows:
Code:
Private Sub cboSchemeID_Change()

    If cboLevelID.Value = Null Then
        cmdPreview.Enabled = False
    Else
        cmdPreview.Enabled = True
    End If

End Sub
The cboLevelID list box does not contain anything and returns a Null value, but does not equal Null for some reason and therefore the code jumps to the Else part of the IF. I have tried adding a copy of the cboLevelID (cboDummyBlank) onto the form and putting
Code:
If cboLevelID.Value = cboDummyBlank.Value Then
But once again this skips to the Else.

Thanks for any help as I was hoping this would be a quick bit of code!
 
Use:

If IsNull(cboLevelID.Value) Then

combo
 
To check for null, space or ZLS:
Private Sub cboSchemeID_Change()
cmdPreview.Enabled = (Trim(cboLevelID.Value & "") <> "")
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you for both for your help, all working now.

Gareth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top