Results 1 to 14 of 14
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246

    Unanswered: Hiding command buttons

    Hi,
    I want to hide a command button on a form depending on the value of another field on that record. The form in question is a continuous form.

    I've tried the OnCurrent event of the form with the following code

    Private Sub Form_Current()

    txtTechnician
    Technician ="Review"
    Print_ac.visible = true
    Technician else
    Print_ac.visible = false

    End Sub

    The command I want to see is called "Print_ac" but only when the value for the field "Technician" = "Review"

    This isn't working, obviously my code is wrong, I'm assuming its the first line, but as I know very little - 10 about VB, thats not surprising!!!

    Can anyone piont me in the right direction

    Regards
    John

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: Hiding command buttons

    Originally posted by Sticker
    Hi,
    I want to hide a command button on a form depending on the value of another field on that record. The form in question is a continuous form.

    I've tried the OnCurrent event of the form with the following code

    Private Sub Form_Current()

    txtTechnician
    Technician ="Review"
    Print_ac.visible = true
    Technician else
    Print_ac.visible = false

    End Sub

    The command I want to see is called "Print_ac" but only when the value for the field "Technician" = "Review"

    This isn't working, obviously my code is wrong, I'm assuming its the first line, but as I know very little - 10 about VB, thats not surprising!!!

    Can anyone piont me in the right direction

    Regards
    John
    Private Sub Form_Current()

      if Me.txtTechnician="Review" Then
        Me.Print_ac.visible = True
      else
        Me.Print_ac.visible = Talse
      endif
    End Sub

  3. #3
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi Hammbakka,
    Thanksfor the quick reply, unfortunately I'm getting a "compile error", Method or data member not found. The code is

    Private Sub Form_Current()

    If Me.txtTechnician = "Review" Then
    Me.Print_ac.Visible = True
    Else
    Me.Print_ac.Visible = False
    End If
    End Sub

    So I changed it to

    Private Sub Form_Current()

    If txtTechnician = "Review" Then
    Me.Print_ac.Visible = True
    Else
    Me.Print_ac.Visible = False
    End If
    End Sub

    which solved the error but now the command button doesn't show even when the field "Technician" = "Review"

    Any ideas?

    Regards
    John

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    I make a small mdb for you

    Hope it helps
    Attached Files Attached Files

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    See you later, I have a pause now.
    good luck

  6. #6
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi Hammbakka,
    Thanks for the demo database, the code was the same as I already had, but your demo gave me an idea. The button appears when you are in the record that has the correct properties but what I really want is as follows.

    As its a continuous form, that shows about 12 records, I want those records that meet the criteria to show this button, but those that don't to have no button. ie

    Record 1 Technician = Alan (no button shown)
    Record 2 Technician = Fred (no button shown)
    Record 3 Technician = Sharon (no button shown)
    Record 4 Technician = Mis (no button shown)
    Record 5 Technician = Review (button shown)
    Record 6 Technician = Alan (no button shown)
    Record 7 Technician = Alan (no button shown)
    Record 8 Technician = Gul (no button shown)
    Record 9 Technician = Review (button shown)
    Record 10 Technician = Review (button shown)
    Record 11 Technician = Gul (no button shown)
    Record 12 Technician = Fred (no button shown)

    All these records would be on the same screen. What is currently happening in this examle is that when in record 1 to 4 no button is shown, but in record 5 the button appears for all records, by changing to record 6 to 8 the button disappears again, but on entering records 9 and 10 it reappears for all records, disappearing again when in record 11 and 12 etc. So I only want it to appear against records 5, 9 & 10 but no others.
    Is that is possible

    Regards
    John

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by Sticker
    Hi Hammbakka,
    Thanks for the demo database, the code was the same as I already had, but your demo gave me an idea. The button appears when you are in the record that has the correct properties but what I really want is as follows.

    As its a continuous form, that shows about 12 records, I want those records that meet the criteria to show this button, but those that don't to have no button. ie

    Record 1 Technician = Alan (no button shown)
    Record 2 Technician = Fred (no button shown)
    Record 3 Technician = Sharon (no button shown)
    Record 4 Technician = Mis (no button shown)
    Record 5 Technician = Review (button shown)
    Record 6 Technician = Alan (no button shown)
    Record 7 Technician = Alan (no button shown)
    Record 8 Technician = Gul (no button shown)
    Record 9 Technician = Review (button shown)
    Record 10 Technician = Review (button shown)
    Record 11 Technician = Gul (no button shown)
    Record 12 Technician = Fred (no button shown)

    All these records would be on the same screen. What is currently happening in this examle is that when in record 1 to 4 no button is shown, but in record 5 the button appears for all records, by changing to record 6 to 8 the button disappears again, but on entering records 9 and 10 it reappears for all records, disappearing again when in record 11 and 12 etc. So I only want it to appear against records 5, 9 & 10 but no others.
    Is that is possible

    Regards
    John
    John,

    Do your test and visible reassignment on the Form_AfterUpdate event (or even on the Current event) since all you're doing is toggling the visible flag of the button(s) ...

  8. #8
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi Mike,
    Thanks for the reply,
    I've changed the event to be after_update, but then its visible on all records. OnCurrent its visble on no records unless you are in the record criteria that matches, but then its visble in all records!

    Regards
    John

  9. #9
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by Sticker
    Hi Mike,
    Thanks for the reply,
    I've changed the event to be after_update, but then its visible on all records. OnCurrent its visble on no records unless you are in the record criteria that matches, but then its visble in all records!

    Regards
    John
    Just trying to follow what you're trying to do ... Basically, as you move (troll) thru the records in your continuous forms form you want to hide/unhide a button or series of buttons right?

  10. #10
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Mike,
    What I want to do is those records that meet the specified criteria show the button, but those that don't, do not show this button.

    At the moment if you are in a record that meets the criteria all records (matching or non-matching) show the button or if you are in a record that doesn't match the criteria all records do not show the button (matching or non matching). Obviously if this wasn't a continuous form it would be a problem as each record would display the command button correctly.

    Regards
    John

  11. #11
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by Sticker
    Mike,
    What I want to do is those records that meet the specified criteria show the button, but those that don't, do not show this button.

    At the moment if you are in a record that meets the criteria all records (matching or non-matching) show the button or if you are in a record that doesn't match the criteria all records do not show the button (matching or non matching). Obviously if this wasn't a continuous form it would be a problem as each record would display the command button correctly.

    Regards
    John
    You're starting to confuse me here ... WHERE are these buttons located at? In each row? in the footer? Explain how you've setup this form ...

    This should be simple ... If the row you select meets the criteria then the buttons are enabled, if not well ...

  12. #12
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Mike,
    The button is one each record (each Row)

    I've attach a screen shot to show what's happening. Currently in this screen shot the cursor is in a record that meets the criteria (green) and so shows the command button, but unfortunately also for those that don't meet the criteria (non green). When I move to a record that does not meet the criteria (non green) the buttons disappear but they should still be visible for those records that meet the criteria (green). This is using the ONCurrent event for the form. After update shows them permanently.

    Regards
    John
    Attached Thumbnails Attached Thumbnails buttons.jpg  

  13. #13
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by Sticker
    Mike,
    The button is one each record (each Row)

    I've attach a screen shot to show what's happening. Currently in this screen shot the cursor is in a record that meets the criteria (green) and so shows the command button, but unfortunately also for those that don't meet the criteria (non green). When I move to a record that does not meet the criteria (non green) the buttons disappear but they should still be visible for those records that meet the criteria (green). This is using the ONCurrent event for the form. After update shows them permanently.

    Regards
    John
    I see! Well why didn't you say that in the 1st place? ... No conditional formatting allowed on buttons ... Hmmm ...

    I don't think you can ... How about moving the button outside to the footer and enabled/disable as you move from 1 record to the next?

  14. #14
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi Mike,
    Thanks for the reply. I guess your suggestion to move it to the footer/header is the only answer if it can't be done at record level.

    Many thanks for your time on this

    Regards
    John

Posting Permissions

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