Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Unanswered: Show / Hide command button via combobox selection & displayed record

    Hello,

    Im trying to show/hide a command button (cmd97) on a form. The form Default View is set to Single.

    There is a combobox (combo107) on the form with a "Yes" / "No" option for the particular record being viewd. The combobox "yes" / "no" selection is stored to a table for that particular record.

    There are also "Next" & "Previous" command buttons to move through the records on the form

    If, on a particular record the combobox is "yes" then I want to show the command button.

    If, on a particular record the combobox is "no" then I want to hide the command button.

    I also want the command button (cmd97) to be shown or hidden when I move through records on the form via the "Next" & "Previous" buttons depending on wether the combobox was set to "Yes" or "No" for each record.

    I have tried this code in the combobox after update, and the "Next" & "Previous" command button onclick events, but cannot get it to work, the button vanishes and doesnt re-appear -
    Code:
    If Combo104.Value = Yes Then
    Command97.Visible = True
    Else
    Command97.Visible = False
    End If
    I need to know in which events I need to be placing the code

  2. #2
    Join Date
    Aug 2011
    Location
    Indianapolis, IN, USA
    Posts
    41
    Try putting Me! before the control name.

  3. #3
    Join Date
    Aug 2004
    Posts
    364
    It doesnt seem to make any difference..

  4. #4
    Join Date
    Aug 2011
    Location
    Indianapolis, IN, USA
    Posts
    41
    I think the "yes" and "no" in your combo box are strings. When you test, you must enclose in quotes.

    If Combo104.Value = "Yes" Then
    Command97.Visible = True
    Else
    Command97.Visible = False
    End If

    I would have DIMed a variable and put the value of the Combobox in the variable then tested the variable. Don't know if it's necessary but it makes it a lot easier for me to read. Something like:

    DIM strResult as string
    strResult = me!Combo104
    If strResult = "Yes" Then
    ... etc.

  5. #5
    Join Date
    Aug 2004
    Posts
    364
    Bingo! Thanks, that is sorted it, I would never have thought of that in a million years!

    Thanks heaps!

Posting Permissions

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