Function erroring out

Skip Bisconer

Who Me?
Local time
Today, 12:54
Joined
Jan 22, 2008
Messages
285
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
 
Last edited:
Not DoCmd.Setwarnings = True
but Docmd.Setwarnings True
 
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.
 

Attachments

  • Switchboard error.jpg
    Switchboard error.jpg
    10.8 KB · Views: 145
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??
 
Skip,

I believe that the SwitchBoard is suppressing your real error message.

Do your queries run without error from the Database Window?

Wayne
 
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.
 

Attachments

  • MacroError.jpg
    MacroError.jpg
    29.8 KB · Views: 136
Actually this attachment is the halt I get. I rushed to post without finishing the routine.
 

Attachments

  • MacroError1.jpg
    MacroError1.jpg
    22.1 KB · Views: 132
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
 
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?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom