MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 18th, 2002, 02:55 PM   #1
dhoffman
New Member
 
Join Date: Apr 2002
Location: Lawrence, KS
Posts: 29
Default

I have a worksheet where two columns of data come from a database and the other columns are calculations based upon the other columns. There is a drop down box on the sheet that the user uses to select what data is loaded from the database. Basically, based upon what is chosen in the drop down box a query will run that will return an unpredictable number of records. Each record is used to fill out one row of the two columns mentioned above. Now I want the user to be able to easily delete a row/record from the database. I have thought about including a textbox or userform where the user can enter the row number to be deleted and then click on a delete button and have a delete query ran on the database, that's one boring ugly way to do it. But what would really be nice is if when the user right clicked on the row number at the left of the sheet and then selected delete from the right-click menu that action would cause code to run that ran a delete query on the database. I guess what I need is a delete_event, but there doesn't appear to be a delete_event, the closest being a selection_change event. But the selection_change event doesn't seem to help becasue there doesn't seem to be any way to determine if a selection was deleted when a selection_change occurs. Mi amigos, please help me!
dhoffman is offline   Reply With Quote
Old Apr 18th, 2002, 03:52 PM   #2
dhoffman
New Member
 
Join Date: Apr 2002
Location: Lawrence, KS
Posts: 29
Default

somebody better answer me or there will be gosh darnit to donate on volunteer!
If in somebody's opinion they think I'm out of luck or what I want to do is stupid at least say so!
dhoffman is offline   Reply With Quote
Old Apr 18th, 2002, 03:57 PM   #3
Jack in the UK
Board Regular
 
Join Date: Feb 2002
Posts: 3,065
Default

easy fellor.. i post HARD questions and often get no replys, and im gutted at nil responce, but a pal em,ailed bluntly and commented

matbe what you want no one knows, not they wont say, or maybe the guys who know have not seen, so dont dispair.

i pass on these warm kind comments.

and i sadly dont really know the answer ill read again and post some thoughts.. but you post has been read.. not ignored...


__________________
Free Excel based Web Toolbar available here.

Jack in the UK
J & R Excel Solutions
"making Excel work for you"
Jack in the UK is offline   Reply With Quote
Old Apr 18th, 2002, 04:00 PM   #4
Jack in the UK
Board Regular
 
Join Date: Feb 2002
Posts: 3,065
Default

gosh darnit to donate on volunteer

sorry i cant read or undrestand this????

can i ask for explain, im english and my read writting is poor, i say this often, im losty. expalingn please.....

__________________
Free Excel based Web Toolbar available here.

Jack in the UK
J & R Excel Solutions
"making Excel work for you"
Jack in the UK is offline   Reply With Quote
Old Apr 18th, 2002, 04:01 PM   #5
davers5
Board Regular
 
Join Date: Feb 2002
Posts: 255
Default

It's not that what you are doing is stupid, it's that your explanation of the question makes it sound like a very hard problem, which I think it is (a very advanced problem anyway).

Anyway, why can't you just have a delete button that runs on a normal click event. The user can select a field in a record and then click the delete button and you can run a delete query. I guess there probably is a way to do the same thing by adding a menu item to the right click but I have no idea how to do that. That would be very cool though!

Dave
davers5 is offline   Reply With Quote
Old Apr 18th, 2002, 04:19 PM   #6
Tommy Bak
Board Regular
 
Join Date: Feb 2002
Location: Guderup, Denmark
Posts: 287
Default

Hi
First macro adds a new menuline to the ROW RightClick menu. Make that run from Workbook_open event

Second macro deletes it. Use together with the workbook_close event

Third macro should be your own deletequery.

Sub ContextInsert()
Dim Menupunct As Object
ContextMenuInsert = "---> &Delete From Database <---"
On Error GoTo err
Application.CommandBars("Cell").Controls(ContextMenuInsert).Delete
err:
Set Menupunct = CommandBars("Row").Controls.Add
With Menupunct
.Caption = ContextMenuInsert
.OnAction = "DeleteQuery"
End With
End Sub

Sub ContextDelete()
ContextMenuInsert = "---> &Delete From Database <---"
Application.CommandBars("Row").Controls(ContextMenuInsert).Delete
End Sub

Sub Deletequery()
MsgBox "Here the deletequery should have been", vbInformation, "Demo"
End Sub


regards Tommy
Tommy Bak is offline   Reply With Quote
Old Apr 18th, 2002, 04:33 PM   #7
dhoffman
New Member
 
Join Date: Apr 2002
Location: Lawrence, KS
Posts: 29
Default

I hope I wasn't hostile sounding. Perhpas I get a little carried away, that babbling didn't really make any sense in any language.
To the last post, I'll have to look at that code more closely, it involves some stuff I haven't used before, which is probably the best kind of help to get, so thanks.
dhoffman is offline   Reply With Quote
Old Apr 19th, 2002, 12:43 PM   #8
dhoffman
New Member
 
Join Date: Apr 2002
Location: Lawrence, KS
Posts: 29
Default

I tried out that code, it was exactly what I was looking for. I have never tried to learn anything about customizing menus before but obviously it is a good thing. Thanks a lot.
dhoffman is offline   Reply With Quote
Old Apr 19th, 2002, 01:18 PM   #9
Cosmos75
Board Regular
 
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
Default

dhoffman,

How do I pull records from a database, mush less have two two update each other? What would be the access code for what Tommy Bak gave?

Am trying to lean VBA for excel and Access. I appreciate any help you can give
Cosmos75 is offline   Reply With Quote
Old Apr 19th, 2002, 01:24 PM   #10
Jack in the UK
Board Regular
 
Join Date: Feb 2002
Posts: 3,065
Default

chris D or any of my frriends i do not understandering, my above post asked what some think ment???? please has the post under explainged me this as i feel i dont get the gist of this easier.

cheers as ever to my friends to help me on this,,, im lost... dam i wish i had a better school...
__________________
Free Excel based Web Toolbar available here.

Jack in the UK
J & R Excel Solutions
"making Excel work for you"
Jack in the UK is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 02:45 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes