Announcement

Collapse
No announcement yet.

If Then Statments Erroring Out

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • If Then Statments Erroring Out

    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

  • #2
    Re: If Then Statments Erroring Out

    ------------------------------------------------------------------------------------------------------------
    please wrap your code between [code] tags, that is a lot easier to read and edit!!!
    ------------------------------------------------------------------------------------------------------------

    try this:
    If oDeptName = "21000" Then
    <do the same for the other If Then statements>

    You can compare a string only to a string value.
    While a number can also be compared with a string containing numbers, but not visa-versa when the strings contains any character.

    \Rems
    Last edited by Rems; 10th October 2007, 20:40.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: If Then Statments Erroring Out

      Thanks \REMS!!!!!!


      You DA MAN!!!!!!!!

      Works good now!!

      Comment

      Working...
      X