Results 1 to 7 of 7
  1. #1
    Ant_Snell is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2021
    Location
    UK
    Posts
    118

    Opening a specific record on a sub-form.

    I would like to open a sub form on a specific record but can’t seam to get the syntax right.



    The main form is: frm_Index_Employee_HR

    The sub-form is: frm_Emp_Details_Current

    The App_ID field is the record I want to open where it equals the App_ID field of the form I am on when running the code.

    DoCmd.OpenForm "frm_Index_Employee_HR", , , "App_ID=" & App_ID
    Successfully opens the main form but does not go to the correct record on the sub-form

    DoCmd.OpenForm "frm_Emp_Details_Current", , , "App_ID=" & App_ID
    Successfully opens the correct record but not as a sub-form within frm_Index_Employee

    I have tried various combinations of syntax Like: forms!frm_Index_Employee_HR!frm_Emp_Details_Curren t
    To say sub-form within the main form but unsucsessfully.

    Can anyone help with how this should look.
    Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    I would have thought your subform would be linked by App_ID ?, so if you get to that main record, you would see the linked records?
    So how is the subform linked.

    You could pass in the App_ID as OpenArgs, and if present the set focus to subform and find first App_ID
    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
    Ant_Snell is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2021
    Location
    UK
    Posts
    118
    Hi Welshgasman


    The bigger picture is that the App_ID is the Key field in the applicant table. I am trying to append all the applicant details of a successful applicant to the employee table, then open the employee record on the new employee that’s just been appended. The App_ID is also appended in order to link back things like reference tables but App_ID is not the key field in the employee table, Emp_ID is.


    All the append bit works fine, I am just struggling to get the newly appended recorded in the frm_Emp_Details_Current sub-form to open on the correct record.


    I have not used OpenArgs before so if this what I should be using could you so syntax please?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    https://docs.microsoft.com/en-us/off....form.openargs

    I am suggesting OpenArgs, so you can open the form without it normally? If a value exists in OpenArgs, then you carry out the process you are attempting here.
    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
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Would it not make more sense to have all the same fields/details in one table, and if the HireDate is Null, they're not an employee?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Ant_Snell is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2021
    Location
    UK
    Posts
    118
    Micron, Thanks, Yes I did consider that and posted question asking for an opinion on 1 or 2 tables before I started the design. I opted for 2 tables in the end because I didn't want to clog up the employees table with potentially 100s of records that will never be viewed as they never become employees. I now have an applicant table that can be regular purged for GDPR reasons and an employee table with just employees, I do however filter current and historic employees.

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Please post a screen shot of your main form\subform with the child\master fields details.

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

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

Similar Threads

  1. Replies: 7
    Last Post: 07-29-2018, 11:58 AM
  2. Replies: 3
    Last Post: 10-03-2015, 05:53 AM
  3. Replies: 5
    Last Post: 01-24-2015, 12:59 AM
  4. Opening Form to a Specific Record
    By PPat in forum Forms
    Replies: 9
    Last Post: 04-24-2013, 08:47 PM
  5. Help with opening form to specific record
    By manic in forum Programming
    Replies: 7
    Last Post: 09-18-2012, 08:44 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