If Then Else problem

davesmith202

Employee of Access World
Local time
Today, 11:48
Joined
Jul 20, 2001
Messages
522
I have the following code that doesn't seem to work properly.

Code:
        If Forms!frmDefaults!Ad1Headline = "" Then
        MsgBox "1"
            Forms!frmDefaults!Ad1Headline = Me.Title
        ElseIf Forms!frmDefaults!Ad2Headline = "" Then
        MsgBox "2"
            Forms!frmDefaults!Ad2Headline = Me.Title
        End If

Field Ad1Headline has a value in it, but I don't get to see "2" popup. Is there something obvious I am missing?

Thanks,

Dave
 
Howzit

"2" will only pop up if AD2Headline is an empty string. If it is Null or has a value, nothing happens.
 
I want to check if it is null or an empty string. What is the best way of doing this?
 
try this - untested

Code:
If Forms!frmDefaults!Ad1Headline = "" or isnull(Forms!frmDefaults!Ad1Headline) Then
        MsgBox "1"
            Forms!frmDefaults!Ad1Headline = Me.Title
        ElseIf Forms!frmDefaults!Ad2Headline = "" or isnull(Forms!frmDefaults!Ad2Headline) Then
        MsgBox "2"
            Forms!frmDefaults!Ad2Headline = Me.Title
        End If
 

Users who are viewing this thread

Back
Top Bottom