Results 1 to 5 of 5
  1. #1
    simon123 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    12

    Adding a new record based on selected record in subform

    Hello all, long time lurker and first time poster. I am sure this has come up before but I am not sure how to work it in the search terms, so apologies in advance



    I am a new user to Access and getting to grips with it, without delving into the scary waters of VBA and SQL.

    I have created a subform on a tab control. I want to create a pop-up form, which is related to the subform, so I can enter and edit records

    Click image for larger version. 

Name:	AccessPlsHelpMe.PNG 
Views:	16 
Size:	43.2 KB 
ID:	33959

    This form represents a two day course, where the DT are the delivery team who are running the programme on each day. The subform on the tab control shows the date and time of each session and when the click the button Add/Edit DT - the floating form pops up to display the DT on that particular day. So far so good, it works and only shows people who are running the programme on that day - thing is, I want to be able to add more DT members to that session and when I try to add someone, I get a pop-up saying it cannot find a record based on the matching fields, and I get it's because I am not adding any data to the ID field (I have hidden it on the pop-up form).

    Is there a way of entering new records on the pop-up form, where it "assumes" the ID field based on the record in the subform where I clicked the button, so the user doesn't have to add it themselves.

    Relationships as follows:
    Click image for larger version. 

Name:	AccessPlsHelpMe2.PNG 
Views:	15 
Size:	41.2 KB 
ID:	33960

    I hope this makes sense - please treat me like an idiot

    Thanks

    simon

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Requires code to pass value between independent forms. Use form/subform arrangement and code not needed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    simon123 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    12
    Hi June7

    Thanks for your reply.

    I will have a google of subform arrangement to pass a value through to the second form. Thanks

  4. #4
    simon123 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    12
    Hi Again!

    So I have added a macro to the button which creates a variable. I am then trying to pass this into any new record on the new form (using a macro on load event) but the field I want to populate remains blank. The variable is working as I have a text box displaying the number but the new record doesn't do anything. Is am wondering if this may be because I have created a 'multiple items' form.

    Thanks in advance!

    Click image for larger version. 

Name:	AccessPlsHelpMe3.PNG 
Views:	12 
Size:	71.3 KB 
ID:	33964

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Code would have to be in Current event. I don't use macros. Also never used TempVars. In VBA, something like:

    If Me.NewRecord Then Me!BookingDateTimeID = TempVars!tmpBookingTimeID

    As soon as record is initiated by entering data into another field, the Current event should trigger and populate ID.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 7
    Last Post: 10-16-2017, 09:49 AM
  2. Replies: 6
    Last Post: 05-09-2017, 09:13 AM
  3. Replies: 2
    Last Post: 03-03-2015, 07:20 AM
  4. Replies: 6
    Last Post: 08-22-2012, 03:24 AM
  5. Replies: 14
    Last Post: 05-25-2012, 02:40 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