Results 1 to 7 of 7
  1. #1
    Lhoj is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2021
    Posts
    92

    Automatically select a record on a datasheet subform through onclick event

    I have a form with a number of subforms on datasheet view. These subforms are non editable, but clicking on the PK of any of the records take you to a form where you can edit the data of said record (that form is accessible through other means, but wanted to set up a shortcut from there). That's done through an Onclick event on the PK field of each subform. The problem is that clicking on the PK field of any record other than the currently selected one opens the form for the selected record, user has to manually select the desired record from the side, then click on the PK field.



    Is there any way to do that through the onclick event? Any way to make it select the record corresponding to the row you're clicking on while on datasheet view?

    Thanks in advance

  2. #2
    Lhoj is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2021
    Posts
    92
    Nevermind, the problem was that the field was disabled so clicking on it wouldn't select the record but still triggers the event. Now, the question stands: Is there any way to make the onclick event select the row you're clicking on without enabling the field?

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Why not just use up/down arrow key to move to the desired record? You could also use record selector buttons on the far left but might get confused by highlighting a bunch of rows, although the active record will be bordered by a coloured line. If you've prevented selecting a record via mouse then your only other options are keyboard moves or switch to continuous form view and add a button if you don't mind a button on every record.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,859
    Try locking the control?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    I use the double-click event to navigate to related forms as click is too prone to activated by mistake.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I agree with posts 4 and 5, as long as users can accept that while it seems that the control can be edited, it can't.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Lhoj is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2021
    Posts
    92
    Yep, that's the way i have it right now, enabled and locked. I would have preferred to keep it disabled, but I'm guessing the answer to my last question is no. Still pondering about making it a double click event, not a big fan but it sure does prevent opening the new form accidentally, specially if the user tries to select the PK for copying it or whatever.

    Thank you all for your tips, case closed

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-23-2016, 08:39 PM
  2. Replies: 9
    Last Post: 09-17-2016, 01:01 PM
  3. Replies: 2
    Last Post: 04-08-2015, 04:06 PM
  4. Replies: 8
    Last Post: 08-26-2012, 11:11 PM
  5. Replies: 5
    Last Post: 02-06-2012, 03:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums