Results 1 to 5 of 5

Thread: Select Case

  1. #1
    Join Date
    Oct 2004
    Posts
    16

    Unanswered: Select Case

    I have never used a "select Case" before, but here is what I am trying to do:

    Private Sub txtPropState_AfterUpdate()
    Select Case "txtPropState"

    Case "NY"

    If txtPropState = "NY" Then
    If recNumberMain Mod 2 = 0 Then
    txtUnderwriter = "Ticor"
    Else
    txtUnderwriter = "Old Republic"
    End If
    End If

    Case "PA"

    If txtPropState = "PA" Then
    If recNumberMain Mod 2 = 0 Then
    txtUnderwriter = "Ticor (PA)"
    Else
    txtUnderwriter = "Old Republic (PA)"
    End If
    End If
    End Select
    End Sub

    It is not working please help!

  2. #2
    Join Date
    Oct 2004
    Posts
    105
    hi i think its you dont need the lines i put in <> and is txtPropState a textbox?
    if you want to check what the text written in that textbox is the you have to do that with txtPropState.Text
    I hope that helps


    Private Sub txtPropState_AfterUpdate()
    Select Case "txtPropState"
    Case "NY"

    <If txtPropState = "NY" Then>
    If recNumberMain Mod 2 = 0 Then
    txtUnderwriter = "Ticor"
    Else
    txtUnderwriter = "Old Republic"
    <End If>
    End If

    Case "PA"

    <If txtPropState = "PA" Then>
    If recNumberMain Mod 2 = 0 Then
    txtUnderwriter = "Ticor (PA)"
    Else
    txtUnderwriter = "Old Republic (PA)"
    End If
    <End If>
    End Select
    End Sub

  3. #3
    Join Date
    Oct 2004
    Posts
    16
    Thank you so much, I actually came up with the same solution except for some reason it won't let me refer to "txtPropState" in the If statements but everything else worked out perfectly.
    Thanks for taking the time to help!

    Jen

  4. #4
    Join Date
    Oct 2004
    Posts
    105
    glad i could help have a good day

  5. #5
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    The extra IF statements within the select are unneccessary, so:

    Code:
    Private Sub txtPropState_AfterUpdate()
    
      Select Case txtPropState.Text
    
        Case "NY"
          If recNumberMain Mod 2 = 0 Then
            txtUnderwriter = "Ticor"
          Else
            txtUnderwriter = "Old Republic"
          End If
    
        Case "PA"
    
          If recNumberMain Mod 2 = 0 Then
            txtUnderwriter = "Ticor (PA)"
          Else
            txtUnderwriter = "Old Republic (PA)"
          End If
    
      End Select
    End Sub
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •