Record Selector [Event Procedure]

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jschmidt
    New Member
    • Jun 2007
    • 47

    Record Selector [Event Procedure]

    All,

    I am trying to have something happen on a form whenever the record selectors are clicked. This is access 2003. I tried the form's click event and that does not work at all.

    Anyone know how I can get a procedure to trigger everytime the form's record selector is pressed?

    Thanks to everyone. This is driving me crazy and any help that can be offered is greatly appreciated.

    Thanks!
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    When you click on the record selector you're moving to another record, and the form's OnCurrent event is triggered, so that would be the appropriate event for whatever you're trying to do.

    Linq ;0)>

    Comment

    • FishVal
      Recognized Expert Specialist
      • Jun 2007
      • 2656

      #3
      Hi, jschmidt.

      Actually there is no specific event to respond to record selector click.
      But with a little workaround it could be sorted.
      When record selector is clicked Form_Click event is fired, but it is fired as well when other form area (but the objects firing their own click event, e.g. detail section background, controls etc.) receives mouse click.
      You may try to distinguish between these clicks using Form.SelHeight property which returns how many rows are selected. Really, when you click on record selector one row is selected otherwise no row is selected.

      [code=vb]
      Private Sub Form_Click()
      If Me.SelHeight = 1 Then
      'code handling record selector click goes here
      MsgBox "Record selector clicked"
      End If
      End Sub
      [/code]

      Regards,
      Fish

      P.S. Actually, this doesn't work in datasheet view when record is already selected.

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        I'm sorry, but when the Record Selector is clicked, the OnCurrent event does fire, even in Datasheet View, does it not?

        Linq ;0)>

        Comment

        • FishVal
          Recognized Expert Specialist
          • Jun 2007
          • 2656

          #5
          Originally posted by missinglinq
          I'm sorry, but when the Record Selector is clicked, the OnCurrent event does fire, even in Datasheet View, does it not?

          Linq ;0)>
          I'm sorry too, but no Form_Current event is fired when clicking on record selector. I mean this bar on the left side of the form where triangle and pen icons appear.
          Do you mean the same or do you mean navigation bar?

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            What do you think happens when you "click" on the record selector? Access moves from whatever record has focus to the record you clicked on. This record then becomes the the "current" record!

            Place this code behind a datasheet form:
            Code:
            Private Sub Form_Current()
             MsgBox "The OnCurrent Event has fired!"
            End Sub
            Now click on the Recored Selector and see what happens.

            Linq

            Comment

            • FishVal
              Recognized Expert Specialist
              • Jun 2007
              • 2656

              #7
              Apologies, Linq.

              And what will happen if you click on record selector of current record? In single form view there is no other option. ;) And what If you just move to another record?

              Kind regards,
              Fish

              Comment

              • missinglinq
                Recognized Expert Specialist
                • Nov 2006
                • 3533

                #8
                Originally posted by fishval
                And what will happen if you click on record selector of current record? In single form view there is no other option. ;) And what If you just move to another record?
                Nothing would happen, of course! But why would you want whatever code the OP wants to tie to the event to happen again? The record selector isn't a command button, to be clicked willy-nilly; its purpose is to move to another record.

                Comment

                • FishVal
                  Recognized Expert Specialist
                  • Jun 2007
                  • 2656

                  #9
                  Originally posted by missinglinq
                  Nothing would happen, of course! But why would you want whatever code the OP wants to tie to the event to happen again? The record selector isn't a command button, to be clicked willy-nilly; its purpose is to move to another record.
                  Post deleted, content PMed.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32633

                    #10
                    It is nevertheless true that the Form_Current() procedure does not directly reflect clicking on a record selector I'm afraid Linq.

                    There are other ways of navigating between records than using the record selectors. I suspect it's also true to say that clicking on the record selector of the current record will not trigger the event.

                    It may possibly be used as an acceptable approximation, but it's not a direct answer for the question. Without knowing exactly what the OP requires we can only guess what may be acceptable for their particular requirements.

                    Comment

                    • Bruce52
                      New Member
                      • Apr 2013
                      • 1

                      #11
                      It works!

                      Originally posted by missinglinq
                      What do you think happens when you "click" on the record selector? Access moves from whatever record has focus to the record you clicked on. This record then becomes the the "current" record!

                      Place this code behind a datasheet form:
                      Code:
                      Private Sub Form_Current()
                       MsgBox "The OnCurrent Event has fired!"
                      End Sub
                      Now click on the Recored Selector and see what happens.

                      Linq
                      Linq

                      Works like a charm! I needed a combo box to show or not show based on the value of another control while viewing records using the record selectors. After unsuccessfully trying a number of events I decided to search online. Bingo...the very answer I was searching for. Thank you much!

                      Comment

                      Working...