If Then Statments Erroring Out

Home Forums Scripting General Scripting If Then Statments Erroring Out

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    MetalSmith
    Member
    #128195

    Ok need a little help here again. When my variable oDeptName contains a number this subroutine does not error. When the person enters a oDeptName value that has a letter it errors out and will not complete the rest of the subroutine.

    Anyone have an idea how to get the If Then statement to understand that if the oDeptName value is anything but a number it will see this and deal with it so the script will continue on? Adding On Error Resume Next only does not work.

    Thanks!!!!!

    Sub PlaceUser
    On Error Resume Next
    If oDeptName = 21000 Then
    Set oDomain = GetObject(“LDAP://OU=xxx,OU=xxx,DC=xxx,DC=xxx,DC=com”)
    Set oUser = oDomain.Create(“user”, “CN=xxx”)
    oUser.Put “sAMAccountName”, “xxx”
    oUser.SetInfo
    ElseIf oDeptName = 22000 Then
    Set oDomain = GetObject(“LDAP://OU=xxx,OU=xxx,DC=xxx,DC=xxx,DC=com”)
    Set oUser = oDomain.Create(“user”, “CN=xxx”)
    oUser.Put “sAMAccountName”, “xxx”
    oUser.SetInfo
    ElseIf oDeptName = 23000 Then
    Set oDomain = GetObject(“LDAP://OU=xxx,OU=xxx,DC=xxx,DC=xxx,DC=com”)
    Set oUser = oDomain.Create(“user”, “CN=xxx”)
    oUser.Put “sAMAccountName”, “xxx”
    oUser.SetInfo
    Else
    MsgBox “Please Enter a Valid Department Number”, 48, “Department Number Verification”
    Call DeptName
    End If
    End Sub

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.