Right click to enter datasheet mode

Autoeng

Why me?
Local time
Today, 16:11
Joined
Aug 13, 2002
Messages
1,302
I used to be able to right click on my continuous form and change to datasheet view which made copy and paste much simpler however I was worried about an autonumber column that was visable in datasheet view so I disabled it. I decided to fool around with the design a bit more to see if I could get the column to hide and stay hidden but can't get the right click to work anymore.

I have form Default View set to Continuous Forms and Views Allowed set to Both but still can't get the right click to change to datasheet view.

What am I overlooking?

OK found what I was overlooking but now how to get around it. I have code (courtesy GHudson) that hides the command bar. When the menu bar is hidden you cannot right click.

Code:
Dim i As Integer
    For i = 1 To CommandBars.Count
    CommandBars(i).Enabled = False
    Next i

I don't want to display the command bar. Is there anyway to allow right click and not display the command bar?

Autoeng
 
Last edited:
AutoEng I'm not sure if this helps you or not but have you tried setting up your own shortcut custom menu and just put on the features you want - Just a thought.

Hay
 
You need to ensure that the "Shortcut Menu" option is enabled. Tools/Startup... and ensure the "Allow Default Shortcut Menu" is checked.

Also, you could hide the menu bars and command bars with this method...

Code:
Public Function ToolbarsOff()
On Error GoTo Err_ToolbarsOff

    ' Turns off the 'custom' Designer Toolbar.
    DoCmd.ShowToolbar "Designer Toolbar", acToolbarNo
    ' Turns off the Database toolbar.
    DoCmd.ShowToolbar "Database", acToolbarNo
    ' Turns off the Relationship toolbar.
    DoCmd.ShowToolbar "Relationship", acToolbarNo
    ' Turns off the Table Design toolbar.
    DoCmd.ShowToolbar "Table Design", acToolbarNo
    ' Turns off the Table Datasheet toolbar.
    DoCmd.ShowToolbar "Table Datasheet", acToolbarNo
    ' Turns off the Query Design toolbar.
    DoCmd.ShowToolbar "Query Design", acToolbarNo
    ' Turns off the Query Datasheet toolbar.
    DoCmd.ShowToolbar "Query Datasheet", acToolbarNo
    ' Turns off the Form Design toolbar.
    DoCmd.ShowToolbar "Form Design", acToolbarNo
    ' Turns off the Form View toolbar.
    DoCmd.ShowToolbar "Form View", acToolbarNo
    ' Turns off the Filter/Sort toolbar.
    DoCmd.ShowToolbar "Filter/Sort", acToolbarNo
    ' Turns off the Report Design toolbar.
    DoCmd.ShowToolbar "Report Design", acToolbarNo
    ' Turns off the Print Preview toolbar.
    DoCmd.ShowToolbar "Print Preview", acToolbarNo
    ' Turns off the Toolbox toolbar.
    DoCmd.ShowToolbar "Toolbox", acToolbarNo
    ' Turns off the Formatting (Form/Report) toolbar.
    DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarNo
    ' Turns off the Formatting (Datasheet) toolbar.
    DoCmd.ShowToolbar "Formatting (Datasheet)", acToolbarNo
    ' Turns off the Macro Design toolbar.
    DoCmd.ShowToolbar "Macro Design", acToolbarNo
    ' Turns off the Visual Basic toolbar.
    DoCmd.ShowToolbar "Visual Basic", acToolbarNo
    ' Turns off the Utility1 toolbar.
    DoCmd.ShowToolbar "Utility 1", acToolbarNo
    ' Turns off the Utility2 toolbar.
    DoCmd.ShowToolbar "Utility 2", acToolbarNo
    ' Turns off the Web toolbar.
    DoCmd.ShowToolbar "Web", acToolbarNo
    ' Turns off the Source Code Control toolbar.
    DoCmd.ShowToolbar "Source Code Control", acToolbarNo

Exit_ToolbarsOff:
    Exit Function

Err_ToolbarsOff:
    MsgBox Err.Number & " " & Err.Description
    Resume Exit_ToolbarsOff

End Function
Code:
Public Function ResetToolbars()
On Error GoTo Err_ResetToolbars

    ' Turns on the 'custom' Database Design Toolbar.
    DoCmd.ShowToolbar "Designer Toolbar", acToolbarYes
    ' Turns on the Database toolbar.
    DoCmd.ShowToolbar "Database", acToolbarYes
    ' Turns on the Relationship toolbar.
    DoCmd.ShowToolbar "Relationship", acToolbarWhereApprop
    ' Turns on the Table Design toolbar.
    DoCmd.ShowToolbar "Table Design", acToolbarWhereApprop
    ' Turns on the Table Datasheet toolbar.
    DoCmd.ShowToolbar "Table Datasheet", acToolbarWhereApprop
    ' Turns on the Query Design toolbar.
    DoCmd.ShowToolbar "Query Design", acToolbarWhereApprop
    ' Turns on the Query Datasheet toolbar.
    DoCmd.ShowToolbar "Query Datasheet", acToolbarWhereApprop
    ' Turns on the Form Design toolbar.
    DoCmd.ShowToolbar "Form Design", acToolbarWhereApprop
    ' Turns on the Form View toolbar.
    DoCmd.ShowToolbar "Form View", acToolbarWhereApprop
    ' Turns on the Filter/Sort toolbar.
    DoCmd.ShowToolbar "Filter/Sort", acToolbarWhereApprop
    ' Turns on the Report Design toolbar.
    DoCmd.ShowToolbar "Report Design", acToolbarWhereApprop
    ' Turns on the Print Preview toolbar.
    DoCmd.ShowToolbar "Print Preview", acToolbarWhereApprop
    ' Turns on the Toolbox toolbar.
    DoCmd.ShowToolbar "Toolbox", acToolbarWhereApprop
    ' Turns on the Formatting (Form/Report) toolbar.
    DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarWhereApprop
    ' Turns on the Formatting (Datasheet) toolbar.
    DoCmd.ShowToolbar "Formatting (Datasheet)", acToolbarWhereApprop
    ' Turns on the Macro Design toolbar.
    DoCmd.ShowToolbar "Macro Design", acToolbarWhereApprop
    ' Turns on the Visual Basic toolbar.
    DoCmd.ShowToolbar "Visual Basic", acToolbarWhereApprop
    ' Turns on the Utility1 toolbar.
    DoCmd.ShowToolbar "Utility 1", acToolbarWhereApprop
    ' Turns on the Utility2 toolbar.
    DoCmd.ShowToolbar "Utility 2", acToolbarWhereApprop
    ' Turns on the Web toolbar.
    DoCmd.ShowToolbar "Web", acToolbarWhereApprop
    ' Turns on the Source Code Control toolbar.
    DoCmd.ShowToolbar "Source Code Control", acToolbarWhereApprop

Exit_ResetToolbars:
    Exit Function

Err_ResetToolbars:
    MsgBox Err.Number & " " & Err.Description
    Resume Exit_ResetToolbars

End Function
You might have to modify a few lines but this will get you started with the right idea.

HTH
 
Thanks ghudson. I knew you would come through for me. You are a life saver.

Autoeng
 
Ghudson:

I probalby not doing something right but haven't been able to figure it out yet. Placed the code in a module (correct?). But when the db starts the Form View toolbar is still showing. I also want to hide the Menu bar as well. Tried adding to the code...
Code:
 DoCmd.ShowMenuBar , acMenuBarno
but get a Variable not defined error. Allow Default Shortcut Menus was checked.

If you could help out again I would appreciate it.

Autoeng
 
You need to look at all of the options I listed and find the toolbars you want (or don't want).

' Turns off the Form Design toolbar.
DoCmd.ShowToolbar "Form Design", acToolbarNo
' Turns off the Form View toolbar.
DoCmd.ShowToolbar "Form View", acToolbarNo

HTH
 
I just pasted the entire turn off code as I don't want any tool bars showing. Still the Form View toolbar is visable. I double checked that the toolbar Form View. I wonder why it isn't hiding that one?

And do you know if there is any call to hide the menu bar?

Autoeng
 
Can you post a shell (no data and just a couple of forms) of your db in Access 97? I will look at it tonight.
 
I use A2K and have code that doesn't go back in some instances so that is out. Looking back through some of your old posts about hiding toolbars I found this
An added bonus is the right click option is disabled if the menu bars are disabled with this code.
in this one http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=37002&highlight=hide+toolbar.

I think that I had also read somewhere on Microsoft that when the Menubar is hidden that it disables the right mouse button. Is there any way to leave the right mouse button active but not display the Menubar (or toolbars).

Autoeng
 
Autoeng,

Check out the attached sample. It has two different methods of hiding/disabling toolbars and menu bars.

This db has two custom menu bars. The "Database Default Toolbar" menu bar is empty which gives the illusion of no menu bars when it is the only one showing. You can easily import and rename the "Database Default Toolbar" menu bar into your A2K application. The "HideResetAllToolbarsAndMenubars" form has the method that is easiest to customize and will allow the right click option to still work.

HTH
 

Attachments

Thanks ghudson,

Your patience is appreciated.

That was exactly what I needed!

Can you help me out with this last item? In my form in Form View I have a hidden field (contains an autonumber so that the info stays in the sequence that it was entered) that becomes a visable column once I enter Datasheet View. I have tried right clicking it to hide it but it always come back. Do you know a way to programatically hide a column in datasheet view?

Thanks again,
Autoeng
 
Last edited:
I have never allowed my users the option to view a form in datasheet view. I am a control freak and prefer to use a subform if the data must be viewed in a grid.

I just played with a test form and when I had the form in datasheet view, I hid some columns and then I saved the form (File\Save) while in the datasheet view. The hidden columns are still "hidden" no matter how I open the form into the datasheet view.

HTH
 
Thanks ghudson,

I will play with it a bit more. Like I said previously I got it to work using your form but when I put the toolbaroff command in my On Open event I get the attached error. Any idea what might be causing it? Otherwise it is working.

Autoeng
 

Attachments

  • error1.jpg
    error1.jpg
    38.3 KB · Views: 304
Can you post your OnOpen code?

Also, can you confirm the names of the custom menu bars (tool bars) you have in your db.

Thanks!
 
Never mind. I figured it out. The properties for your menu bars default to Toolbar. Once I reset these all is fine with the world and my db.

Again, thank you ghudson.

Autoeng
 

Users who are viewing this thread

Back
Top Bottom