locked
switchboard choices giving error message RRS feed

  • Question

  • I have created three switchboards (created using Access 2013) for use with a database that previously worked as expected but now some of the choices are giving me the following error message: "An expression in argument 3 has an invalid value."

    I had these switchboards working in a test DB and, as they all were working as expected, exported them to the production DB. It is in the production DB that they are giving this message.

    The structure of the three switchboards is: switchboard1 is for administrators/Dept heads and consists of  choices to launch the other two switchboards and choices only for admins. Switchboard 2 is for authorized office users and consists of choices pertaining only to their department. Finally, switchboard 3 is for the shipping/receiving department and, like the office users, contains only choices for those authorized in that department.

    The menu choices that are generating this message seem to be one of two types:

    1)  Going to a different switchboard (a command "1" in the switchboard table leading to a correct switchboard #, item# 0, command# 0 in the table) OR

    2) Opening a form in either add or edit mode (command 2 or 3 in the switchboard table).

    I have visually traced all the switchboard numbers, item numbers and commands in the switchboard table and they all check out OK. I have checked the forms for proper record sources and they all check out OK.

    My questions is: where do I find this argument 3 the error message refers to so I can see what expression has the invalid value? I don't believe it is referring to the argument column in the related switchboard table.

    Any help is welcomed and appreciated....

    John

    Thursday, October 12, 2017 2:46 PM

Answers

  • OK... I found the solution!

    It centers around a couple things. In my case, because I was using multiple switchboards within one database, I was forced to give them different names. The tables and forms need to be the same names (i.e. switchboard abc items (table name) and switchboard abc (form name). These need to be identical! Secondly, and this is where the error message (an expression in argument 3 has an invalid value) is generated... You need to open the affected form in design view, open the properties window, choose OptionLabel1, and click on the OnOpen Embedded Macro ellipsis to reveal the coding. This is the Macro coding for the switchboard commands (1, goto switchboard; 2, open form in add mode; 3, open form in edit mode, etc.). You'll find an OnError Macro first in the list, then an If statement referencing [command] = 1. There are two Set Properties for the Label 1 and Label 2 controls. It is within these statements my error was occurring. The commands that referenced the tables for the forms (switchboard abc items - referenced above - for the switchboard abc form) were referencing the incorrect switchboard name (following the above example, it referenced switchboard items instead of switchboard abc items)! I changed that to the correct switchboard name (switchboard abc items) and, voila! everything now works!

    Hope this helps others.....

    • Proposed as answer by Chenchen Li Thursday, October 19, 2017 1:48 AM
    • Marked as answer by Kip320 Wednesday, January 9, 2019 6:45 PM
    Wednesday, October 18, 2017 1:40 PM

All replies

  • Hi John,

    Did you use the Switchboard Manager to create the switchboards? If so, when you exported them to the production database, did you also export the table to go along with it?

    Just curious...

    Thursday, October 12, 2017 2:50 PM
  • Yes... I created all three using the switchboard manager and then renamed them (the switchboards AND the associated tables) in the test DB and then exported them to the production DB.
    Thursday, October 12, 2017 3:02 PM
  • If you renamed the table, did you tell the form what the new name was?
    Thursday, October 12, 2017 3:05 PM
  • Yes....
    Thursday, October 12, 2017 3:07 PM
  • Then, the only other way I can think of to trace the problem is to step through the code. Do you know how to do that?
    Thursday, October 12, 2017 3:17 PM
  • No.... Could you tell me the steps?
    Thursday, October 12, 2017 3:37 PM
  • Open the switchboard in design view and then select the button you want to troubleshoot. In the Click event, click on the ellipsis to open the code window. Click on the gray vertical bar to the left on the line of code where you want to start troubleshooting the problem. Then, view the switchboard as normal and click on the button. The code should pause and highlight the line of code you marked earlier. You can then examine any variables set up to this point. To execute the next line, you can hit the F8 key. Keep doing this until you figure out where the problem is.

    Hope it helps...

    Thursday, October 12, 2017 3:43 PM
  • Great! BUT.... when I open the switchboard in design view, there is only one button - not several - As I understand switchboards (certainly not an expert on them :) ), it is the table and underlying code of the switchboard manager that populates the form and creates the form buttons that are displayed.

    I'll try your instructions and report back.....

    Thursday, October 12, 2017 3:57 PM
  • OK.... So, I opened the switchboard in design view, selected the button, clicked on the OnClickEvent ellipsis and it takes me to a macro tools context tab and design mode. I see no vertical line to the left that is "clickable" only a dimmed out, collapsed navigation bar. There are several macro steps that are expanded on this screen.
    Thursday, October 12, 2017 4:08 PM
  • When I click on the first step of the macro (OnError) and then click on single step, then click run, it just starts stepping me through the Option1 macro. That appears to be the macro that controls the switchboard because it enumerates the commands (1 - go to switchboard, 2 - open form in add mode, 3 - browse form in edit mode, etc.
    Thursday, October 12, 2017 4:24 PM
  • Hi,

    I'm sorry for the confusion. I didn't realize you're using embedded macros rather than vba. I'm not sure how to help you without being able to see what you got. Is there any way you can share your work for examination?

    Thursday, October 12, 2017 4:36 PM
  • Unfortunately, probably not. the program belongs to my employer and he probably wouldn't want it out in cyberspace. If I can figure out a way to put just the switchboard stuff out there, I'll see if he'd be OK with that. I won't see him until sometime next week. In the meantime, I might just try creating new switchboards in the production version....

    Thanks for your help thus far!

    If anyone else might have some ideas, let's hear 'em! 

    Thursday, October 12, 2017 4:44 PM
  • Good luck! Let us know how it goes.
    Thursday, October 12, 2017 4:51 PM
  • OK... I found the solution!

    It centers around a couple things. In my case, because I was using multiple switchboards within one database, I was forced to give them different names. The tables and forms need to be the same names (i.e. switchboard abc items (table name) and switchboard abc (form name). These need to be identical! Secondly, and this is where the error message (an expression in argument 3 has an invalid value) is generated... You need to open the affected form in design view, open the properties window, choose OptionLabel1, and click on the OnOpen Embedded Macro ellipsis to reveal the coding. This is the Macro coding for the switchboard commands (1, goto switchboard; 2, open form in add mode; 3, open form in edit mode, etc.). You'll find an OnError Macro first in the list, then an If statement referencing [command] = 1. There are two Set Properties for the Label 1 and Label 2 controls. It is within these statements my error was occurring. The commands that referenced the tables for the forms (switchboard abc items - referenced above - for the switchboard abc form) were referencing the incorrect switchboard name (following the above example, it referenced switchboard items instead of switchboard abc items)! I changed that to the correct switchboard name (switchboard abc items) and, voila! everything now works!

    Hope this helps others.....

    • Proposed as answer by Chenchen Li Thursday, October 19, 2017 1:48 AM
    • Marked as answer by Kip320 Wednesday, January 9, 2019 6:45 PM
    Wednesday, October 18, 2017 1:40 PM
  • Hi Kip,

    Congratulations! Glad to hear you got it sorted out. I knew the only way to find the source of the problem was by tracing the code. Good luck with your project.

    Wednesday, October 18, 2017 2:53 PM
  • Hello,

    Thanks for sharing the solution. I suggest you mark the post as answer to close this thread.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 19, 2017 1:49 AM