Code converted from macro doesn't work 
Author Message
 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.



Sat, 30 Oct 2004 04:08:14 GMT  
 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
    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.



Sat, 30 Oct 2004 04:08:20 GMT  
 Code converted from macro doesn't work
On Mon, 13 May 2002 16:08:14 -0400, Renee Moffett

Quote:

>The code and error explanation is below.  Thanks to all who can help.

Eyuck. Another reason to hate macros.

I take it that the intended goal is to copy all records from
tblLibrarySearch to the table behind sbfrmPLUSDirOrderDetails? If so,
I'd suggest some much shorter and simpler VBA. Create an Append query
appending tblLibrarySearch to that table, and execute the query from
code:

Private Sub OrderALL_Click()
Dim db As DAO.Database
Dim qd As DAO.Querydef
Set db = CurrentDb
Set qd = db.Querydefs("YourAppendQueryName")
qd.Execute dbFailOnError
Set qd = Nothing
End Sub

                  John W. Vinson[MVP]    
    Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public



Sat, 30 Oct 2004 07:16:13 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Converted macro doesn't work in runtime.

2. Converted macro doesn't work in runtime.

3. Converting to Access 2002 Code doesn't work

4. old code - new browser - code doesn't work

5. Code doesn't work (from Dev's site)

6. Debugger doesn't work on Macros for Word in Office XP

7. Macro doesn't work in Word2000

8. Macro doesn't work in Word2000

9. WHY DOESN'T THIS WORK - MACRO!

10. Passing binary data as a (unicode) string to API is converted and doesn't work

11. fRefreshLinks Doesn't work if path doesn't exist

12. Command button doesn't execute macro when added via code

 

 
Powered by phpBB® Forum Software