if then else (1 Viewer)

Thedon123

Registered User.
Local time
Today, 13:05
Joined
Sep 11, 2002
Messages
98
I have a problem. a user selects a values in an cascading combo.
when he reaches the last one he clicks on select. this gives him an msg box telling the code of the last combo.

what i am trying to do is to give him an error if there is nothing in the last combo. i.e it is blank which means the msgbox cannot display any code.

i have used the code below. the problem is that the code doesnt recognise the "" as a null value, so how do make it recognise a null value.


Private Sub SelectSRO_Click()

If Me!SearchOperations.Value = "" Then
MsgBox "There is no value"
Else
MsgBox "Please enter or select " + "'" + Me!SearchOperations.Value
End If
DoCmd.Close acForm, "SRO_Search_Add"



End Sub
 

wh00t

Registered User.
Local time
Today, 13:05
Joined
May 18, 2001
Messages
264
If IsNull Me!SearchOperations Then
MsgBox "There is no value"
Else
MsgBox "Please enter or select " + "'" + Me!SearchOperations.Value
End If
DoCmd.Close acForm, "SRO_Search_Add"
 

PaddyIrishMan

Registered User.
Local time
Today, 13:05
Joined
Jun 5, 2002
Messages
166
try using .text = "" instead of .value = ""

Hope this helps!
 

Mile-O

Back once again...
Local time
Today, 13:05
Joined
Dec 10, 2002
Messages
11,316
Private Sub SelectSRO_Click()

If Me!SearchOperations.Value = vbNullString Then
MsgBox "There is no value"
Else
MsgBox "Please enter or select " + "'" + Me!SearchOperations.Value
End If
DoCmd.Close acForm, "SRO_Search_Add"



End Sub
 

Thedon123

Registered User.
Local time
Today, 13:05
Joined
Sep 11, 2002
Messages
98
.text didnt work but the answer from from wh00t
worked

thanks a lot to both of you for your help
 

sambo

Registered User.
Local time
Today, 05:05
Joined
Aug 29, 2002
Messages
289
Here is a good utility I think I picked up on this site..
You can pass any data type into this function to find out if there is anything in it.

Code:
Function IsNothing(varToTest As Variant) As Integer
'  Tests for a "logical" nothing based on data type
'  Empty and Null = Nothing
'  Number = 0 is Nothing
'  Zero length string is Nothing
'  Date/Time is never Nothing

    IsNothing = True

    Select Case VarType(varToTest)
        Case vbEmpty
            Exit Function
        Case vbNull
            Exit Function
        Case vbBoolean
            If varToTest Then IsNothing = False
        Case vbByte, vbInteger, vbLong, vbSingle, vbDouble, vbCurrency
            If varToTest <> 0 Then IsNothing = False
        Case vbDate
            IsNothing = False
        Case vbString
            If (Len(varToTest) <> 0 And varToTest <> " ") Then IsNothing = False
    End Select

End Function
 

WitchCraft

Registered User.
Local time
Today, 13:05
Joined
Jan 6, 2003
Messages
11
Try this :

Private Sub SelectSRO_Click()

If isnull(Me!SearchOperations.Value) Then
MsgBox "There is no value"
else

If Me!SearchOperations.Value = "" Then
MsgBox "There is no value"
Else
MsgBox "Please enter or select " + "'" + Me!
SearchOperations.Value
End If
endif

DoCmd.Close acForm, "SRO_Search_Add"
 

Users who are viewing this thread

Top Bottom