If Statement / Else - Getting Stuck

CharlesWh

Registered User.
Local time
Today, 12:43
Joined
Jan 19, 2006
Messages
36
I'm working on my Db; when a customer record form is opened the system checks the status of their IP Address. But some will not have an IP address listed. So I'm trying to code in that if the IP address field is bank then to exit the routine but i seem to be getting stick and have an error message else without if??

Code:
'Display The Status Of The IP Address
If Me.CustRelationshipType = "2" Then

    If Me.txtRadIPaddress Is Null Then
    Exit Sub
  Else
      
Dim strComputer As String
    strComputer = txtRadIPaddress
    If Not SystemOnline(strComputer) Then

'Display A Message / or Action
        'MsgBox "Local IP Ping Test Failed: " & strComputer, vbOKOnly, "Failed"
        Me.txtIPstatus = "Fail"
                  
    Else
                 
        'MsgBox "Local IP Test Successful", vbOKOnly, "Passed"
        Me.txtIPstatus = "Online"
        
    End If
  DoCmd.SetWarnings True
  Else: End If
   
End Sub
 
I will take "why do I keep my code clean and indented?" for 500 dollars

Code:
'Display The Status Of The IP Address
    If Me.CustRelationshipType = "2" Then
        If Me.txtRadIPaddress Is Null Then
            Exit Sub
        Else
            Dim strComputer As String
            strComputer = txtRadIPaddress
            If Not SystemOnline(strComputer) Then
                'Display A Message / or Action
                'MsgBox "Local IP Ping Test Failed: " & strComputer, vbOKOnly, "Failed"
                Me.txtIPstatus = "Fail"
            Else
                'MsgBox "Local IP Test Successful", vbOKOnly, "Passed"
                Me.txtIPstatus = "Online"
            End If
            DoCmd.SetWarnings True
    Else: 
    End If
   
End Sub
You are missing an "End if" and seem to have a "spare" Else
 

Users who are viewing this thread

Back
Top Bottom