Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2002

    Unanswered: inserting a new linked record automatically on another form

    I have 2 forms: Form A & B. They are separate forms, not subforms,
    that are linked only by their Form# (which is an autonumber field in both forms). What I'd like to do is when a user creates a new record in Form A, that a corresponding new record is created in Form B automatically. I am not well-versed in VB. I'd appreciate any and all input. Thanks in advance!!!!!

  2. #2
    Join Date
    Aug 2002
    Northampton, England
    You can't open Form B with the primary key field being Autonumber. You will have to change it to number. The following code will open a second form in add mode and take over the Autonumber.

    Private Sub Command4_Click()
    Dim DocName As String
    Dim LinkCriteria As String

    DocName = "FormB"
    LinkCriteria = "[IDB] = Forms![FormA]![IDA]"
    DoCmd.OpenForm DocName, , , LinkCriteria, A_ADD

    Forms![FormB]![IDB] = Forms![FormA]![IDA]

    End Sub

    If you have the ID field set to autonumber in the second form you will get runtime error 2448. 'You can't assign a value to this object'


  3. #3
    Join Date
    Nov 2002

    runtime 2448 error

    I too have this error, having placed a duplicate record macro on a command button...
    My table has many hundreds of records in it, what would be the consequences of changing the ID to something other than autonumber, and is it as easy as right clicking on the field and changing the property?
    many thanks

  4. #4
    Join Date
    Nov 2002
    Hillsboro, OR, USA

    Question Duplicate record?

    Do you want:

    a] both forms pointing to the same record in the same table?
    b] the second form to pointing to a duplicate record in another table?
    c] the second form to pointing to a duplicate record in the same table?

    Please clarify.


  5. #5
    Join Date
    Nov 2002
    What my user wants is a quick way of entering a record onto a form.
    We thought we might be able to do this by adding a command button and assigning the "duplicate record" macro to it.
    Once the record is duplicated she would just change the values in the relevant fields....
    Thanks for your help...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts