UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Record Will Not Save, Access 2016    
 
   
River59
post Feb 11 2019, 01:45 PM
Post#1



Posts: 1,601
Joined: 7-April 10
From: Detroit, MI


I have a few forms with subforms. They all work fine except for one. There is a 'Save' button that will close the form (should save the record), then it will send an email. The body of this email is dependent upon reading this record.

I have tried to force the save, which doesn't work either. But ... AFTER the email part is sent, the table will show the record. I thought it just wasn't saving and updating the record in time so I added a DoEvent to try to slow it down. This doesn't work either. This does not work on either of the if statements.

I don't understand why the other forms work and this one will not. I can send an email on the 'Save' routine on the other forms and they all write to the table and the information is picked up in the email.

CODE
        Dim Msg, Style, Title, Help, Ctxt, Response, MyString
        Msg = "Select 'Yes' to close and send email." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Select 'No' to to back."
        Style = vbYesNo + vbExclamation + vbDefaultButton1
        Title = "Cancelling confirm"
        Response = MsgBox(Msg, Style, Title)

        If Response = vbNo Then
            Exit Sub

        Else
            [Forms]![frm_MainDashboard]![txtPDFName] = Null

            If (Me.cmbTempSys) <> "FDR Crown" Then
                [Forms]![frm_AddSysDetails]![sfrm_AddSysDetails].Form.[txtTempID] = Me.txtTempID
                [Forms]![frm_AddSysDetails]![sfrm_AddSysDetails].Form.[txtTempSys] = Me.cmbTempSys
                
                DoCmd.RunCommand acCmdSaveRecord
                TempSys = [Forms]![frm_AddSysDetails]![sfrm_AddSysDetails].Form.[txtTempSys]
                
                DoCmd.Close acForm, "frm_AddSysDetails"
                DoCmd.RunSQL "UPDATE tbl_TemplateSysDetails SET tbl_TemplateSysDetails.CreatedBy = UCase([Forms]![frm_MainDashboard]![txtUserID]) WHERE (((tbl_TemplateSysDetails.TemplateID)=[Forms]![frm_MainDashboard]![txtTempID]));"
                
                DoEvents
            Else
                DoCmd.Close acForm, "frm_AddSysDetails"
                DoCmd.RunSQL "UPDATE tbl_TemplateSysDetails SET tbl_TemplateSysDetails.CreatedBy = UCase([Forms]![frm_MainDashboard]![txtUserID])"
                DoEvents
            End If

            DoEvents

        MsgBox "These template system details have been saved."

        Call EmailNotification(Att, strFileName)

End If


I have wasted 2 days trying to get this to work. I have commented out the code for the 'Save' event, compiled and saved. I have removed all of the code for the 'Save' event compiled, saved, compact/repair, the pasted the code back in from Notepad. I have created a clean database, brought in everything but the code behind this 'Save' event, then pasted the code from Note Pad. Nothing seems to make this record show up on the table before the email routine runs.

Any ideas where to go from here?
This post has been edited by River59: Feb 11 2019, 01:46 PM

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 
River59
post Feb 11 2019, 02:28 PM
Post#2



Posts: 1,601
Joined: 7-April 10
From: Detroit, MI


Once again, I figure a problem out as soon as I post it ...

The reason it was not writing to the table is because the subform never received the focus if the System was not FDR Crown. I solved this by setting focus to the subform before closing it.

Problem solved. dance.gif woohoo.gif thumbup.gif

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    23rd February 2019 - 03:47 AM