Results 1 to 6 of 6
  1. #1
    easyrider is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2021
    Location
    Lancaster County, PA
    Posts
    44

    DoCmd.GotToRecord acGoTo throws error "2105 You can't go to the specified record"

    Racking my brains here on this one.



    I have a main form with a continuous form as a sub form. The main form displays the current record while the continuous sub form displays all of the users in the table, which is what I want. Both are bound to the same table - UserGroupT. I would like to be able to double-click a user on the sub form and make that record current on the main form. I have created the double-click event with the following code:

    DoCmd.GoToRecord acDataForm, "MainForm", acGoTo, x (where x is the PK of the user's record in UserGroupT)

    But it throws error 2105 "you can't go to the specified record"

    I have verified that the double-click event gets the correct value for x from the sub form. Even if I replace x with a valid number of the PK in the UserGroupT, it still throws the same error. I've also placed a temporary command button on the main form with a valid PK number and it throws the same error.

    What am I missing here or maybe I should use another method to change the main form's current record?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Why not look at the syntax of the command?

    https://learn.microsoft.com/en-us/of...cmd.gotorecord

    Can you now see the likely issue?

    What is the value of X ?

    Possibly use FindFirst http://www.java2s.com/Code/VBA-Excel...tFindFirst.htm
    Or FindRecord https://learn.microsoft.com/en-us/of...ecommendations (not used this one myself)
    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

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    You might consider a split form which automatically deals with a single table in the manner that you described.

  4. #4
    easyrider is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2021
    Location
    Lancaster County, PA
    Posts
    44
    Ding, Ding, Ding! Cranial Light Bulb Illumination Alert!

    Ah, the offset parameter is the number of the record and not the PK of the record! And that number is based on the order of the subform - alphabetically in this case, which doesn't coincide with the order of the records in the table. If I change the subform OrderBy property to match the UserGroupT - the PK in this case - then it works. But I think the subform looks sloppy when the names aren't alphabetized.

    Thanks for the links - I'll go check them out and see if I can keep that little light bulb lit up!

  5. #5
    easyrider is offline Advanced Beginner
    Windows 11 Access 2010 32bit
    Join Date
    Dec 2021
    Location
    Lancaster County, PA
    Posts
    44
    Update. If I set the Order By property of the main form to 'Name' and do the same for the sub form, then it works. Thanks for the replies, guys!

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    I would also consider a split form or an emulated split form.
    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

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

Similar Threads

  1. Replies: 5
    Last Post: 04-08-2021, 09:15 AM
  2. Replies: 3
    Last Post: 07-28-2017, 12:12 PM
  3. Replies: 7
    Last Post: 06-02-2017, 10:40 AM
  4. Replies: 1
    Last Post: 03-26-2015, 11:31 PM
  5. Replies: 6
    Last Post: 01-29-2014, 08:03 AM

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