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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use right mouse button to change from form to datasheet view

Status
Not open for further replies.

Autoeng

Technical User
Jul 16, 2002
57
US
I have a form with several "columns" that resembles an Excel spreadsheet. Because it is a form when you paste information into it you can only do one field (cell) at a time. However if I right click on the form and select (Change to datasheet view) I can paste entire rows.

Now for the problem. I don't want any menubar or toolbar showing in my application for my users. I hide them with the following code.

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

Then use a hidden button on my form to redisplay them so that I can work on the db.
Code:
Dim I As Integer 
For I = 1 To CommandBars.Count 
CommandBars(I).Enabled = True 
Next I

The problem is that this code also disables the right mouse button so that you can't get to the datasheet view. You might ask, Well why not make the form display in datasheet view all the time? Some of my users are not very good at cutting and pasting and were making a mess out of the information. I do have one user that is very good and I have no problem allowing her to enter data via datasheet mode.

Does anyone know a way to hide the menu and toolbars and still retain the functionality of the right mouse click so that she can change from form to datasheet view? I would even take a command button event if it becomes necessary I just don't want to display the bars as it messes up the form layout.

Autoeng

 
What you want to do is create your own menu bar or tool bar. The menu bar or tool bar you create will contain only the items you want the user to access. For example, you could create a menu bar with just the View Datasheet option available. Then, when the user right clicks, a menubar (submenu) will be displayed.

To create a custom menu bar, goto View|Toolbars...|Customize... Then select the Toolbars tab and select New. Then drag the options you want to the New Toolbar. Give the new toolbar any name you want. In your form, set the ShortCutMenu property to Yes and set the ShortCutMenuBar property to the new menubar you just created.
 
I don't want any menu bars as that would require that I relayout my form to accomodate the area that the menu bar uses. I have found a way around it but it quite lengthly. If anyone has the need for it let me know and I will post it.

Autoeng
 
With a shortcut menubar you don't have to worry about changing the layout of your form. When the user right clicks, a submenu will be displayed right next to the field. When the user selects "Datasheet View" the menu disappears. If the user doesn't want to select "Datasheet View", he/she just has to click someplace else for the submenu to disappear.
 
But using the code I had previously posted the right click is disabled. That is what I was trying to get around. How to have no menu bar but the right click still works.

Autoeng
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top