Still trying to link two forms together

If a form is bound and you make a change, the changes are automatically saved upon moving to another record or closing the form. No code necessary to force the save.

Also, as Rich pointed out, if you were to use code to force a save, you would use

DoCmd.RunCommand acCmdSaveRecord

instead as that other "menu" code is not good to use as it has been deprecated (so they say - the funny thing is that Microsoft themselves in their wizards, even in 2007, use their own obsolete code).
 
so, ATM oncomsave_click we successfully open form2 to the appropriate record, and close the form1. as i see it this should save the changes to the record, unless (i am thinking while i type) this is blocked by the record being open in the second form! (maybe i can figure this one out after $tupid meeting)


Code:
Private Sub comSave_Click()
On Error GoTo Err_comSave_Click
        
     With DoCmd
        'DoCmd.RunCommand acCmdSaveRecord IS 'UNAVAILABLE'
        .openForm "Update", acNormal, , "[keyID]=" & Me!txtkey, acFormEdit, acWindowNormal
        .Close acForm, Me.Name
              
        End With

Exit_comSave_Click:
    Exit Sub

Err_comSave_Click:
    MsgBox Err.Description
    Resume Exit_comSave_Click
    
End Sub

form1 on close should be creating a new record (it isnt)
Code:
Private Sub Form_Close()
DoCmd.RunCommand acCmdRecordsGoToNew
'do i need DoCmd.RunCommand acCmdSaveRecord
End Sub
 
How can you create a new record on Form1 if it's being closed and what would be the point?
 
well in order to have an open record in form1(initial imput) which can link for form2(followupdata) im trying to create a perpetual record machine.

form1 opens 'blank' record
edits it
*saves it (shouldn't this happen on close? well it doesnt work when told, to let alone on its own)
form1 sets record as 'edited'
sends it to form2
closes/creates new 'blank'

form2 continues to editrecord
 
Last edited:
ok so almost everything goes as planned but the values entered into the fields on boundform [Input Form] fail to save to the record.

from the pulldown menu:
Code:
Sub openForm()
  DoCmd.openForm "Input Form", acNormal, , "[EntryStatus] = 0", acFormEdit, acWindowNormal
End Sub

on click event:
Code:
  With DoCmd
     
        .RunCommand acCmdSaveRecord
        
        .RunSQL "UPDATE [tbl Modifications] SET [EntryStatus]=(1) WHERE [keyID]= [txtkey]"
        
        .openForm "Update", acNormal, , "[keyID]=" & Me!txtkey, acFormEdit, acWindowNormal
        
        .Close acForm, Me.Name
              
        End With

onclose:
Code:
Private Sub Form_Close()


With CurrentDb.OpenRecordset("tbl Modifications", dbOpenTable)
        .AddNew
          !EntryStatus = 0
          .Update
End With

End Sub
 
heh. this works now. while i had bound the form, the controls were still unbound. Thanks for all your help guys!
 

Users who are viewing this thread

Back
Top Bottom