Switchboard Error

Tiffosi2007

Registered User.
Local time
Today, 19:26
Joined
Sep 13, 2007
Messages
50
Ok, this seems a bit strange!

I have a very simple switch board, the main sb opens up into 3 sub ones. Each of the sub ones has a few options to open up relevant forms as well as a 'return to main menu' button to go back to the main sb.

The problem is, when i open up a form from a sub menu and then close it (docmd.close) bringing the sb into view again, and select return to main menu i get an error (there was an error excecuting the command). This DOESNT happen when you do not open a form and just naviagate back and forth between the different sb though so it seems as though it may be a problem with the form being opened.
 
I use a simple Menu system on the SubMenu where there is simply a CloseForm and the Main Menu Docmd.Quit. I have never had any problems with the Menu system and I ignored the SwitchBoard concept completely. Menuing was so simple to implement.

Simon
 
Did you make the switchboard using the wizard?
 
Didn't bother just a Menu form with Labels (not even command buttons) then put Menu into Display Form in Startup.

There is a misconception that these wizards are the be all and end all. Some people may not like my solution but it works without fuss!

Simon
 
My point is if it is made by the wizard, the code should be allright. If it is not, then i am curious what is looks like. Otherwise i can't help.
 
Apologies, i have been away the past few days. The SB was made by the wizard, yes. This is why i thought it was so strange that it seems to corrupt. As i said, it works fine when it first opens and you can navigate beween the main sb and the sub ones - until you open another form!
 
Oops

This is not what i meant.

I know what the standard code of the SB wizard looks like. Im more interested in the switchboard table and the commands that where executed.

Seems to me that one of these commands closes your switchboard.
 
A read only copy of your database is useless to anyone trying to help you.
 
Hi Tiffosi2007,

I took a look at your database and I think I see the problem.

In the code behind your Switchboard form, you have made an addition to the wizard generated code. In the HandleButtonClick function, you added these lines of code beneath the conCmdOpenFormAdd Select Case:

'assign the val of strDirecID to the text box on new form
[ItemNumber] = strSB
sbItem = strSB

I'm not entirely clear what you're doing here, but I'm guessing you're trying to pass in the current Switchboard ItemNumber (determined by what sub-menu you're on) to a text box on the forms you open.

The problem occurs because as written you're actually going to *update* that field in the recordset. The first time around, strSB is Null so Access sets ItemNumber to Null, but that's part of the Primary Key of the Switchboard Items table so in essence it can't update the record in the table - which isn't really what you're trying to do I believe.

Make one small change to your code. Change this line:

[ItemNumber] = strSB

to

strSB = [ItemNumber]

Now try it out.

--------------------
Jeff Conrad - Access Junkie - MVP Alumni
SDET - XAS Services - Microsoft Corporation

Co-author - Microsoft Office Access 2007 Inside Out
Presenter - Microsoft Access 2007 Essentials
http://www.accessmvp.com/JConrad/accessjunkie.html
Access 2007 Info: http://www.AccessJunkie.com

----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
 
Genius!!

Thanks for that, i had actually forgotten i had put that code into the SB to be honest. Will give it a go but too be honest i may just remove it.

Thanks for the help!!!!
 
You're welcome, glad we could help.
Good luck with your projects.

--------------------
Jeff Conrad - Access Junkie - MVP Alumni
SDET - XAS Services - Microsoft Corporation

Co-author - Microsoft Office Access 2007 Inside Out
Presenter - Microsoft Access 2007 Essentials
http://www.accessmvp.com/JConrad/accessjunkie.html
Access 2007 Info: http://www.AccessJunkie.com

----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
 

Users who are viewing this thread

Back
Top Bottom