Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2011
    Posts
    413

    Unanswered: Problem with if statement

    If ((me.English = "Fair") Or (me.English = "Fluent")) then
    me.Label205.Visible = True
    Else
    Label205.Visible = False
    End If

    The control English can have 3 values, Learning, Fair, Fluent.

    If it has either Fair or Fluent in it then I want the label to be visible, what am I doing wrong?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    OK so what actually are the values of Me.English
    is it a combobox, a text box, a list box an option group?
    Put a watch on the code and examine what values actually are in me.English
    https://www.google.co.uk/#hl=en&sa=X...w=1366&bih=681

    you could rewrite your code
    Code:
    If me.English = "Learning"
      me.Label205.Visible = false
    Else
      Label205.Visible = true
    End If
    I would expect something like If me.English.value...

    if its an option group something like
    if English.Value = ...
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2011
    Posts
    413
    English is a combo box and the values are Learning which is the default.
    Fair and Fluent are the other values.

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Where do you have your original code placed?

    If the Bound Column of the English Combobox is the Column holding the ratings, it should work fine placed in the English_AfterUpdate and Form_Current events.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so put a breakpoint on the if statement and examine what values 'English' has
    then step through the code and see what happens

    of course whilst debugging you could do something else
    Code:
    If me.English = "Learning" then
      me.Label205.Visible = false
    Elseif me.English = "Fluent" then
      Label205.Visible = true
    Elseif me.English = "Fair" then
      Label205.Visible = true
    else 'it wasn't one of the 3 theoretical values so there is a screw up in the code.
      '..
    End If
    'if there is a screw up in the code
    'either we are using the wrong object for the if
    'or the values in the combo box aren't as we are being told.
    'i would expect this to be effectively an option group using say a numeric value to represent the value of 'English'
    
    msgbox "the value of English was: '" & me.english & "'"
    make certain you put option explicit as the first line in your code.
    as this is changing the visibility of a control I dobt it will do much good in the after update event. 'd want to push this into a function and then call that function from various events such as on current (to set the value on change of record displayed)
    the on change event of the combo box
    and possibly the on ost focus events
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Moreover, it's very possible that the Value property of the combo cannot be something such as "Learning", "Fluent" or anything like that. There probably is a hidden column that's also the bound column of the combo and that determines it's Value property. Open the property windows when the combo is selected on the form in design mode and check the ColumnCount, ColumnWidths and BoundColumn properties of the combo.
    Have a nice day!

Posting Permissions

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