none
MS Access - Form - Open new form with previous form for Edit Record RRS feed

  • Question

  • Hey,

    I have a form in which user search for record, this form have a subform which is a datasheet  in which the required search show up. Then there is a button as Edit Record which open new form for editing. I have 9 fields in subform, when user select record and click edit button the new form which open up shows the previous 8 fields except one field "ID" which is always opening as a new record, i want the ID to be  from the previous form not the new record. I have set Data Entry to be Yes which is required in my form, is there a way to get ID from previous form with data entry to yes.

    Any help would be appreciated.

    Thank you
    Wednesday, November 22, 2017 8:59 AM

All replies

  • The Data Entry property only allows new records to be added. Why is setting it to Yes required for your form?

    If you want to edit the record, then set that value to No. 

    Another question: Why can't the user edit the subform after the search? That would seem more intuitive.


    -- Scott McDaniel, Microsoft Access MVP

    Wednesday, November 22, 2017 10:53 AM
  • Hi Wsm93,

    I agree with the suggestion given by Scott McDaniel MVP regarding editing the data in sub form.

    if the fields are displayed there then why don't you edit the record there instead of opening a new form.

    you had mentioned that there is a button.

    do you want to add a button in datasheet view? or on a main form?

    you cannot add button in datasheetview.

    but you can add button on main form and with help of that you can fetch the value from sub form field and open the form.

    example:

    Private Sub Command2_Click()
    
    Dim frm As Form
    Dim str As String
    Set frm = demo_data2.Form
    
    DoCmd.OpenForm "demo_data2", , , "activity_by=" & frm!activity_by & ""
    End Sub
    

    Output:

    first you can select the record in sub form and click the button to open that record in new form to edit the data.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 23, 2017 2:50 AM
    Moderator