Code converted from macro doesn't work
I've been fighting with this thing all day and hope someone can offer me
an explanation for this. I'm making changes to a form that originally
ran macros on click of buttons. I opened the supporting macro and saved
it as code. I placed the code in the Event Procedure for the buttons in
question. 5 of 6 worked fine. But one is giving me an error when it
runs from code that it does not when run from the macro. The code and
error explanation is below. Thanks to all who can help.
Private Sub OrderALL_Click()
' Echo off
DoCmd.Echo False, ""
' Warnings off
DoCmd.SetWarnings False
' open tblLibrarySearch
DoCmd.OpenTable "tblLibrarySearch", acViewNormal, acEdit
' Select All Records
DoCmd.RunCommand acCmdSelectAllRecords
' Copy all records
DoCmd.RunCommand acCmdCopy
' close tblLibrarySearch
DoCmd.CLOSE acTable, "tblLibrarySearch"
' Go to sbfrmTPPDirOrderDetails
' Forms("myMainForm")("mySubForm")("myControl")
DoCmd.GoToControl "sbfrmPLUSDirOrderDetails"
' Select All Records
DoCmd.RunCommand acCmdSelectAllRecords
' Paste
DoCmd.RunCommand acCmdPaste
DoCmd.Requery "" 'THIS IS THE LINE HIGHLIGHTED WHEN I DEBUG
' Echo on
DoCmd.Echo False, ""
' Warnings on
DoCmd.SetWarnings True
End Sub
The error is Run-time error 3246: Operation not supported in
transactions.
Then I get this message 6 times and have to click OK.
"Operation not supported in transactions."
Why would this work as a macro but not as code? I still have button
supported by the macro and have tested to see that it does work. HELP.