direct user to specific page of a switchboard

AC-Dev

What say you, good sir?
Local time
Today, 01:20
Joined
Jun 20, 2011
Messages
81
sorry if this has been asked already -

I have a db that, on opening, prompts the user to check any expired (or soon to expire) documents via text box. if the user clicks no, nothing happens, if the user clicks yes, i want it to go to the switchboard page that the soon to expire documents is in (they are more than one type of document so there are 5 options in the "Coming Due" switchboard page)

long story short, is it possible to reference a specific page of a switchboard?

Thanks.
 
Try opening the switchboard form with a filter set on the SwitchboardID that you want to see.

If you've constructed your switchboard with the Switchboard Manager there'll be a table of Switchboard items. Look through the table to find the SwitchboardID that contains the page you want to send the user to.

Example: the Switchboard name is "Switchboard" and the SwitchboardID #2 is my page with all the selections I want to be shown first so:

Docmd.OpenForm "Switchboard",acNormal,,"[SwitchboardID]= 2 and [ItemNumber] = 0"

Note: 2 commas after acNormal is correct :)
Presto!
Goh
 
Example: the Switchboard name is "Switchboard" and the SwitchboardID #2 is my page with all the selections I want to be shown first so:

Docmd.OpenForm "Switchboard",acNormal,,"[SwitchboardID]= 2 and [ItemNumber] = 0"

Note: 2 commas after acNormal is correct :)
Presto!
Goh

Alright, i have a slight problem with that lol.

I inputted the code and when the user hits ok, it takes them to the switchboard page but no data shows up. it is basically a blank switchboard page. my code is identical to yours except my switchboard id is 6.

I also tried putting that code in before the switchboard loads the first time but still no go.

Am i missing something here?

Edit: should i refresh the form after i change the id?
 
It sounds like a maybe a Syntax error, copy and paste my statement in the immediate window of you vb editor and try it again. At first don't change any page number, you must have a page 2 if you have a page 6 and ItemNumber 0 is standard if you created the switchboard with the Switchboard Manager.

Let me know your results

Goh

I've observed that if Switchboard is already open int he background then the command works properly but I'm not sure why it does that, otherwise it always seems to open to the default page first.
 
Last edited:
i tried to add your code(copy and paste) and i still have the same "error"
 
I don't see what is wrong here. your code seems like it should work but it still gives me a blank switchboard page
 
Can you show us your Switchboard items table?
Goh
 
i turned it into a pdf file and had to remove certain names for security purposes. layout and numbers have not changed
 

Attachments

Ok everything "LOOKS" fine, try opening a different SwitchboardID because if it's opening a blank page then it's not referencing the values correctly. The only time I get a blank page is when I enter a value that doesn't exist. Also Drop the [ItemNumber] from the command line and see if that does the trick.
Goh
PS be sure that that the items are linked to actual reports. If you selected Open report and then didn't select a report it may not even show the label next to the button, or the button (object/command mismatch). If all else fails, delete the 4 records for Switchboard 6 and then recreate them in the switchboard manager again. Also try compact an repair before going to the trouble of redoing the switchboard.
 
Last edited:
Alright, so dropping the [ItemNumber] does not work and neither does compacting the database. i have tried with all database pages and still nothing. Also i have run into another problem. The titles no longer change when you move to another switchboard like they used to. They would normally be the name of the switchboard and now it is stagnant on the original switchboard name.n i have been doing alot of changes so i suspect that it is not a related issue, but i could be wrong.
 
1) open the Switchboard form in design mode
2) go to form properties
3) make sure your record source still points to the correct table
4) manually delete the information in the property: Filter
5) close and save the Switchboard form
6) Reopen the form: It SHOULD be back to it's original functionality

As for the Switchboard form not applying the designated filter from the DoCmd.... I'm stumped at this point because all my tests work.. there's got to be something else going on there

A) The Switchboard form on_open is set to open the DEFAULT switchboard page which would be the main page you've set probably SwitchboardID = 1
B) Once the Switchboard form has been opened you should be able to change the applied filter with the DoCmd and move to the page you want to view because that is in essence what the VBA in the form does when you click a button on the Switchboard Form as seen in this snippet found in Private Function HandleButtonClick(intBtn As Integer)

' Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument]​
(Basically filtering on ItemNumber] and [SwitchboardID])

C) When all else fails; retrieve your working copy from your backup or delete the switchboard and related items and recreate it...

Goh:o
 
1) open the Switchboard form in design mode
2) go to form properties
3) make sure your record source still points to the correct table
4) manually delete the information in the property: Filter
5) close and save the Switchboard form
6) Reopen the form: It SHOULD be back to it's original functionality

As for the Switchboard form not applying the designated filter from the DoCmd.... I'm stumped at this point because all my tests work.. there's got to be something else going on there

A) The Switchboard form on_open is set to open the DEFAULT switchboard page which would be the main page you've set probably SwitchboardID = 1
B) Once the Switchboard form has been opened you should be able to change the applied filter with the DoCmd and move to the page you want to view because that is in essence what the VBA in the form does when you click a button on the Switchboard Form as seen in this snippet found in Private Function HandleButtonClick(intBtn As Integer)
' Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument]​
(Basically filtering on ItemNumber] and [SwitchboardID])

C) When all else fails; retrieve your working copy from your backup or delete the switchboard and related items and recreate it...

Goh:o

First of all, thank you for the time you are putting in to help a complete stranger. it is nothing less than appreciated :).

Second, my switchboard commands (on open and on current) are all in a macro (from when i used the switchboard manager). would that have any effect on directing the user? i have attempted to change my macros to vba code using the tool in the toolbar, but i get the error :"There was a problem opening the macro '[Embedded Macro]'. Do you want to continue?". when i click 'yes' it gives me the same error again (i presume because i have two macros). when i click 'yes' a second time, my database freezes. should i try to convert it manually and then add the filter code you suggested? or just make the filter code a macro?

as for manually removing the filter in the properties, attempted and still no titles return.
 
I believe that the key to this is to open the switchboard form itself as hidden and then call the HandleButtonClick() event which would normally be called when you click on one of the buttons.

So go to the HandleButtonClick() procedure in the Switchboard form and change PRIVATE to PUBLIC. Then put this function in:
Code:
Function SwBOPs(intButton As Integer)
    DoCmd.OpenForm "Switchboard", windowmode:=acHidden
    Call Forms("Switchboard").HandleButtonClick(intButton)
    Forms!Switchboard.Visible = True
End Function

bob, i do not see this 'HandleButtonClick()' procedure anywhere. my switchboard has no code (all macros) and as i said above, it will not let me automatically convert it to vba. I AM STUMPED!!!!!
 
Can you post a copy of the database?

the whole database? or just my VBA code?
there is alto of sensitive documents and information in it that i am forbidden to disclose so i shall be careful in what i let out.
 
The whole database but you can clear the tables (except the switchboard table) as we only need to look at the switchboard form and table.
can i send it to you in a PM instead?
 
When you say 'error' are you referring to a Database Error with an Error number or just the "unexpected results/no-results/undesireable results" that you are observing which you'd prefer didn't happen. If it's an actual database error with an error number can you tell us what that is.

Goh
 
When you say 'error' are you referring to a Database Error with an Error number or just the "unexpected results/no-results/undesireable results" that you are observing which you'd prefer didn't happen. If it's an actual database error with an error number can you tell us what that is.

Goh

the later - basically it is not doing what i want it to do (opening the switchboard page)
 
I pull your copy but sorry you lost me...I don't have v2007 to open it with, so, I'll leave it to Bob to check on it. Good Luck
Goh
 
I think it is probably not easy to do this directly within the standard MS switchboard.

Maybe one way is to add another switchboard option - and open the switchboard in code with an openargs value. (ie a value other than than the standard actions 1 to 6 (I think its 1 to 6 offhand).

Then if the openargs value is set, you could probably call the handlebuttonclick event with this special action value to force the switchboard to the page you want. This idea also needs you to change the handlebuttonclick event

However, reading the thread again, I presume you are using A2007 or A2010 - which probably explains why you can't see any code.

I am not familiar with the way the macros work in these switchboards, though. Is there no code module at all? Can you see what the handlebuttonclick macro is doing?

(look at a switchboard button and see what the click event handler is set to. That will show you what you are looking for)


Another way might be to open a single form, with the 5 options on it hard coded to buttons, and not open the switchboard normally until you close this special form.


----
just a further thought - in the A2003 version of a switchboard, the switchboard form open event forces the switchboard to open at page 1 of the menu options. I am sure A2007/A2010 versions do the same. Your code needs to find a way to avoid that, in the special case. Maybe that is why Bob's idea is not working. Hence my idea of using openargs to determine exactly how the switchboard was opened.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom