Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    May 2001
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If statements (VBA - Word 97 SR 2 )

    I have a form where I want specific fields to gray out depending on the value in a drop down list - I want it to gray out immediately the option is chosen. THe field I want to gray out is called txtRegion and the combo box is cmbSource. The syntax I have used is as follows

    Private Sub cmbSource_Change()
    If cmbSource.Value = "K (International)" Or "L (International)" Then
    txtRegion.Enabled = True
    Else
    txtRegion.Enabled = False
    End If
    End Sub

    The error it comes up with is type mismatch. Any help would be much appreciated

    Thanks in advance

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If statements (VBA - Word 97 SR 2 )

    Like this:

    If cmbSource.Value = "K (International)" Or <font color=red>cmbSource.Value = </font color=red> "L (International)" Then
    txtRegion.Enabled = True
    Else
    txtRegion.Enabled = False
    End If
    End Sub
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If statements (VBA - Word 97 SR 2 )

    Try

    If cmbSource.Value = "K (International)" Or cmbSource.Value = "L (International)" Then

    instead of

    If cmbSource.Value = "K (International)" Or "L (International)" Then

    The Or operator is a logical operator that acts on boolean values, not on strings.

Posting Permissions

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