Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switchboard: command to display database window 2

Status
Not open for further replies.

Fredgarner

Technical User
Jul 21, 2005
29
GB
I am making a switchboard in form design view and cannot find a command button that will return me to the database window. Does anyone know how I can make one? (There is one on the Northwind sample database).
 
From NorthWind DB
Code:
Sub DisplayDatabaseWindow_Click()
' This code created in part by Command Button Wizard.
On Error GoTo Err_DisplayDatabaseWindow_Click

    Dim strDocName As String
        
    strDocName = "Categories"

    ' Close Main Switchboard form.
    DoCmd.Close
    
    ' Give focus to Database window; select Categories table (first
    ' form in list).
    DoCmd.SelectObject acTable, strDocName, True

Exit_DisplayDatabaseWindow_Click:
    Exit Sub

Err_DisplayDatabaseWindow_Click:
    MsgBox Err.Description
    Resume Exit_DisplayDatabaseWindow_Click
    
End Sub

________________________________________________________________________
Zameer Abdulla
Visit Me
Children are poor men's riches.
 
I would like to make the database useable by people who are not especially computer-literate, so F11 is not really an option. I tried copying and pasting the Northwind code into my database, but this causes errors and does not work. Any other ideas would be gratefully appreciated!
 
Hi, you sure you want to do that? The idea usually is to keep people out of the back end and provide a front end that handles the user's needs. Kind of asking for trouble, I would think.

That aside, add a switchboard item to close the switchboard using your switchboard manager.

Of course, if you do that then you will have to show people how to reopen the switchboard - which sort of defeats the purpose of making it user friendly.

 
As simple as
Code:
Private Sub cmdShowDBWindow_Click()
    DoCmd.SelectObject acTable, [b]ATableName[/b], True
End Sub
Fredgarner said:
I would like to make the database useable by people who are not especially computer-literate, so F11 is not really an option
don't show the db window to them they can do anything including deleting objects



________________________________________________________________________
Zameer Abdulla
Visit Me
Children are poor men's riches.
 
This is very easy. Make a Sendkeys Macro.

If you do not know how to do this: Go to Macros, then New.

Your first and only action will be Sendkeys. Down on the bottom, in the Action Cell: {F11} Type it just like that.

Save it as whatever, I suggest calling it F11 or "Open database window."

Then use the command button wizard to put your button where you want it. Categories: Misc, Action: Run Macro, then pick you macro name. Tell it to display text: Unhide Window.

Good to go.
 
keun,
For many reasons I don't prefer Macro
1)Macros have no error handler that make me crazy in the middle of a macro
2)What Macro can do and more can do by VBA,
3)MS is no more developing macros (as per my knowledge)

And about sendkeys. Sometimes it can be harmful to your PC. Anytime nay other program can take the focus and recieve the sendkey. No idea what will be the result.

And lastly what you have done with macro is very simple in VBA with a line of code..
Code:
Private Sub cmdDisplayDBWindow_Click()
    SendKeys "{f11}"
End Sub

If you need a macro to be run on command click, place a command button cancel the wizard , just select macro from the "OnClickEvent". Not necessary to do it by wizard.

Hope thid helps

________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top