Results 1 to 3 of 3
  1. #1
    Steven19 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2020
    Location
    London
    Posts
    110

    Run time error help 3201

    I have a Form: KYCMenu (Junction Table)


    KYCSegmentKey (Primary Key)
    DDKey (Foreign Key)
    DateKYCCommenced (Short Date)

    I have a command Button that will Populate DateKYCCommenced = Now() (adds to a blank table)

    I then Want to auto populate todays date into a sub table tblKYCBackground
    KYCKey(Primary Key)
    DDKey(Foreign Key)
    BGDateStarted

    The code I have is as below, but it stops at rs.update

    Error code: You cannot add or change a record because a related record is required in the table KYC.

    What am I missing to allow this to run smoothly on one button. Me.DateKYCCommenced = Now() adds a date, and the blank table, but stops.

    Private Sub BtnStartKYC_Click()
    Me.DateKYCCommenced = Now()


    Dim rs As Recordset
    Set rs = CurrentDb.OpenRecordset("tblKYCBackground")
    rs.AddNew
    rs!DDKey = Me.KYCSegmentKey
    rs!BGDateStarted = Now()
    rs.Update
    End Sub

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    You are trying to add a child record when there is no parent record thus the error. I cannot tell from that which is which or even if you've identified the parent table or field. If the parent has something to do with DateKYCCommenced then you have begun a record but haven't saved it before trying to append the child via the recordset. You'll have to save the record first. If Me.Dirty Then Me.Dirty = False might fix the problem if I'm on the right track.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Steven19 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2020
    Location
    London
    Posts
    110
    Quote Originally Posted by Micron View Post
    You are trying to add a child record when there is no parent record thus the error. I cannot tell from that which is which or even if you've identified the parent table or field. If the parent has something to do with DateKYCCommenced then you have begun a record but haven't saved it before trying to append the child via the recordset. You'll have to save the record first. If Me.Dirty Then Me.Dirty = False might fix the problem if I'm on the right track.
    This fixed the issue, thank you. So I am using your suggestion moving forward.
    I was thinking DoCmd.Save - but this didn't feel right.

    Regards

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

Similar Threads

  1. RunTime error 3201
    By a14guguliye in forum Programming
    Replies: 2
    Last Post: 02-07-2020, 09:58 AM
  2. Error 3201
    By JennyL in forum Access
    Replies: 11
    Last Post: 06-15-2018, 11:14 AM
  3. Replies: 5
    Last Post: 04-02-2017, 04:55 PM
  4. Error Handeling for a 3201 and 3022 Error
    By starlancer805 in forum Access
    Replies: 3
    Last Post: 03-11-2015, 12:46 PM
  5. Error 3201 on Form / Subform
    By jerem in forum Programming
    Replies: 2
    Last Post: 12-01-2012, 12:34 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