Issue with IF statements

kepo2019

New member
Local time
Today, 15:47
Joined
Nov 4, 2019
Messages
2
Hi,

I think I'm going insane. I have been messing with this code since early this morning and I cannot figure out why it doesn't work.

Code:
Private Sub Close_Click()
                
    If Me.txt_status.Value = "CLOSED" & Len(Me!Combo88 & vbNullString) = Null Then
    MsgBox "Closed By Field is Required."
Else
    DoCmd.Close acForm, "View_V3"

End If
End Sub

This code will not open a msgbox it just skips over that and closes the form.

Any help would be greatly appreciate.

Thanks,
Kevin
 
Hi Kevin. Instead of using "&", I think you meant to use "AND" in its place.
 
Plus a Len is not going to return Null ??

Code:
tt="Paul"
? len(tt & vbnullstring)
 4 

tt=""
? len(tt & vbnullstring)
 0
 
Hi Kevin. Instead of using "&", I think you meant to use "AND" in its place.

Ahhhh! Thank you! That was a dumb mistake! I've been seriously messing with this for hours.

I did have to change the code around a little - posting it in case anyone else needs it:

Code:
    If Me.txt_status.Value = "CLOSED" And IsNull(Combo88) = True Then
    MsgBox "Closed By Field is Required."

Thank you so much again!!
 
Hi. You're welcome. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom