Save button in Main Form and save it on to Subform and on the Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • QCLee
    New Member
    • Dec 2007
    • 3

    Save button in Main Form and save it on to Subform and on the Table

    Hello Sir, Im here again asking for help. I have a form and a subform relate to HVAC Windward Table. i have a SAVE button on the form that when clicked it saves data on the HVAC Windward Table but not in a subform. When manually inputing data into subform it saves by work order on the HVAC Windward Table in subdatasheet even if how many times i add data in one work order. Sir, Is it posible that when i clicked on the SAVE button in the form it saves the current data both on the HVAC Windward Table and to the subform as in same data in one work order, coz if the work order is "reschedule d" when i clicked SAVE button it will goes to subform and to the table and if re-entry the same work order is completed it will goes again in the subform and to the table, now there are two record in one work order in subform and to the HVAC Windward Table. Is there any code for this? Im using wizard to create SAVE command button and here's the code:

    Code:
    Private Sub Save_Record_Click()
    On Error GoTo Err_Save_Record_Click
    
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    
    Exit_Save_Record_Click:
    Exit Sub
    
    Err_Save_Record_Click:
    MsgBox Err.Description
    Resume Exit_Save_Record_Click
        
    End Sub
    Any help would be appreciated..th anks and god bless!
  • PianoMan64
    Recognized Expert Contributor
    • Jan 2008
    • 374

    #2
    OK, first thing is, that you don't need a save record button on the main form. When the focus of the form changes to the subform the main form record saves automaticly.

    One thing that I need to make sure that is setup correctly is the relationship between the main and sub forms.

    if you get into the properties of the sub form and make sure the following fields are filled out.

    Link Child Field
    Link Master Field

    These two fields are what links the main form to the sub form so the relationship between the information on the main form and the sub form are sync'd

    then when you enter information on the sub form, and long as you go to an new records before you close, then that should autosave the subform records without the need for save or update buttons on the form.

    I hope that helps,

    Joe P.

    Comment

    Working...