Help please! Save Cmd Button not wkng (1 Viewer)

gszdwml

New member
Local time
Today, 07:32
Joined
Apr 24, 2012
Messages
3
I am trying to have a record saved when i click on my "Resolve Alarm and Close Tkt" button on my "ARMS Single Tkt Display" form. This process is supposed to save the record to the "ChronicTkt# T" table , then copy it to the "ClosedTktT", then delete it from the "ChronicTkt# T". The problem I have is that when I type "Yes" in the "Close Tkt" field in my form, it does not save the text when copying over to the new table(ClosedTktT). Also, all records are copied on just the record I am on.


Please see my attached dB file.

My VBA code from my Button


Private Sub Save_and_Close_Form_Click()
DoCmd.DoMenuItem A_FORMBAR, A_EDIT, A_SELECTRECORD
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Save
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Refresh
DoCmd.Requery
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO [ClosedTktT] SELECT * FROM [ChronicTkt# T] WHERE [Chronic Tkt Number] = [Chronic Tkt Number]"
DoCmd.SetWarnings True
DoCmd.DoMenuItem A_FORMBAR, A_EDIT, A_SELECTRECORD
DoCmd.DoMenuItem A_FORMBAR, A_EDIT, A_DELETE
DoCmd.Close
End Sub
 

Attachments

VilaRestal

';drop database master;--
Local time
Today, 15:32
Joined
Jun 8, 2011
Messages
1,046
First thing I notice, it's copying all records because the line
Code:
DoCmd.RunSQL "INSERT INTO [ClosedTktT] SELECT * FROM [ChronicTkt# T] WHERE [Chronic Tkt Number] = [Chronic Tkt Number]"
should be
Code:
DoCmd.RunSQL "INSERT INTO [ClosedTktT] SELECT * FROM [ChronicTkt# T] WHERE [Chronic Tkt Number] = " & Me![Chronic Tkt Number]
 

VilaRestal

';drop database master;--
Local time
Today, 15:32
Joined
Jun 8, 2011
Messages
1,046
And there's a lot of code there for something that should be quite simple. I guess you've been adding lines trying to get it to work.

Does this work:

Code:
Private Sub Save_and_Close_Form_Click()
    RunCommand acCmdSaveRecord
    DoCmd.SetWarnings False
    DoCmd.RunSQL "INSERT INTO [ClosedTktT] SELECT * FROM [ChronicTkt# T] WHERE [Chronic Tkt Number] = " & Me![Chronic Tkt Number]
    RunCommand acCmdDeleteRecord
    DoCmd.SetWarnings True
End Sub
?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom