Open a form to add new record while passing on the value from the previous form

Anonymous
2018-03-01T08:11:44+00:00

i have a subform, sfrmList, with a “new” button at the top, i want to click on the “New” button and it will take me a data entry form “frmAdd” but then also passed on the value “APID” from the subform to the “frmAdd”. The goal is to add new record for the same AIPID. Thank u in advance.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2018-03-01T12:40:50+00:00

    Pass the APID value to the new form as the OpenArgs argument of the OpenForm method.  Open the form in dialogue mode to pause code execution.  Requery the subform when code execution resumes to show the new record in the subform:

        DoCmd.OpenForm "frmAdd", WindowMode:=acDialog, OpenArgs:=Me.APID

        Me.Requery

    In frmAdd's Open event procedure set the DefaultValue property of the APID control to the value passed to the form:

        If Not IsNull(Me.OpenArgs) Then

            Me.APID.DefaultValue = """" & Me.OpenArgs & """"

        End If

    Note that the DefaultValue is always a string expression, regardless of the data type of the column, hence the delimiting literal quotes characters.

    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-03-04T17:02:14+00:00

    Perfect, thank you Ken!

    0 comments No comments