Skip Bisconer
04-01-2008, 01:45 PM
I am trying to run this function through a switchboard and it errors out. In the switchboard I used the option to run code and I entered UpdateAssignedOrdersTable as a function name. I converted this from a macro originally and added the SetWarning to the function. Do I need to do something more to make this work?
Public Function UpdateAssignedOrdersTable()
On Error GoTo UpdateAssignedOrdersTabel_Err
DoCmd.SetWarnings = False
DoCmd.OpenQuery "qryCleartblAssignedDailyOrders", acViewNormal, acEdit
DoCmd.OpenQuery "qryUpdateOEInvoiceHeaderToAssignedDailyOrders", acViewNormal, acEdit
DoCmd.SetWarnings = True
UpdateAssignedOrdersTabel_Exit:
Exit Function
UpdateAssignedOrdersTabel_Err:
DoCmd.SetWarnings = True
MsgBox Error$
Resume UpdateAssignedOrdersTabel_Exit
End Function
petehilljnr
04-01-2008, 08:02 PM
Not DoCmd.Setwarnings = True
but Docmd.Setwarnings True
Skip Bisconer
04-01-2008, 09:07 PM
I have attached an image of the error. It just says there was an error executing this command. I eliminated the = sign and still get the error.
ajetrumpet
04-01-2008, 09:10 PM
Is there any other code running while this is going on?? Is the query file already opened?? Could the file possibly be corrupt?? Could the objects themselves be corrupt?? Do the queries contain complicated syntax??
Is the error occurring on the second command?? Do either of the queries open, or does the function just stop and not open either of them??
WayneRyan
04-01-2008, 09:33 PM
Skip,
I believe that the SwitchBoard is suppressing your real error message.
Do your queries run without error from the Database Window?
Wayne
Skip Bisconer
04-01-2008, 11:28 PM
I think so too, so I made a macro to run the code and attached is an image of the halt I get. Basically it says it can't find a code of that name. It's there in the module window so I don't know why it doesn't recognize the fact that it's there.
Skip Bisconer
04-01-2008, 11:32 PM
Actually this attachment is the halt I get. I rushed to post without finishing the routine.
gemma-the-husky
04-02-2008, 01:07 AM
is this a standard MS switchboard
if so the message you received, as wayne says is a standard message that merely says the switchboard command could not be run.
so how did you put this copmmand IN the switchboard
open the switchboard items table, and see what the options are for this menu command
Skip Bisconer
04-02-2008, 09:47 AM
I just used the manage switchboard wizard and I selected RunCode and typed in the module name the first time. When it errored out I then went into edit mode and copy pasted the module name because I though maybe I had misspelled it. Each way gave me the same halt. I seems the process does not recognize that the module is there. It doesn't run the code when I remark out the setwarnings.
I have made it work properly. I retraced my steps when I originally created the converted macro. I had renamed the module to the same name as the function. This time I left the name as Access made it as "Converted Macro - (Function Name)" and added the Setwarnings on and off to it and it went through the process as it was supposed to do.
Maybe you can't have a module name the same name as a function?