Power Query Course in Spanish
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: i think this is a good question

  1. #1
    New Member
    Join Date
    Apr 2002
    Location
    Lawrence, KS
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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!

  2. #2
    New Member
    Join Date
    Apr 2002
    Location
    Lawrence, KS
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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!

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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"

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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"

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Location
    Guderup, Denmark
    Posts
    288
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  7. #7
    New Member
    Join Date
    Apr 2002
    Location
    Lawrence, KS
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  8. #8
    New Member
    Join Date
    Apr 2002
    Location
    Lawrence, KS
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  9. #9
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  10. #10
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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"

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •