i think this is a good question

dhoffman

New Member
Joined
Apr 1, 2002
Messages
29
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!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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!
 
Upvote 0
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...
 
Upvote 0
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.....
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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...
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top