Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98

    Unanswered: Really stupid question..

    Hi,

    I have a really stupid question and can only think of the sql for this but I'm thinking that it must be possible in VB.

    I want to make a command to delete the current record and generate a warning message.

    I know its a really stupid question but I just don't know what to do.

  2. #2
    Join Date
    Jan 2004
    Location
    Jersey, UK
    Posts
    108
    If you create a macro that deletes the current record, you'll be able to view the code and learn that way.

  3. #3
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98
    Hi,

    I have tried creating a macro but the problem with that is that I get these very strange Error messages all the time. But if I replace the macro's with code the message don't come up.

  4. #4
    Join Date
    Jan 2004
    Location
    Jersey, UK
    Posts
    108
    I just added a button to a form and made sure that the Wizard button was on. The rest is just a case of selecting the options you want: Record Operations, Record Delete. This is the code that it made for me:

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70


    Regards - Andy

  5. #5
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98
    How do you get the code it makes for you? What do you click to see it?

  6. #6
    Join Date
    Jan 2004
    Location
    Jersey, UK
    Posts
    108
    Ok. Add a button to a form. The Wizard should pop up and present a list of options. Choose Record Operations and then select Record Delete. Now click OK or Finish to close the Wizard.

    To see the code, right-click on your button (in Design View) and choose Build Event, select Code and another window should open showing you the 2 lines of code I posted previously.

    Hope that helps.


    Regards - Andy

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    In your button_Click event put the next code


       DoCmd.RunSQL ("DELETE FROM YourTableName WHERE yourField_id='" & txt_FieldContainingTheSameId & "';")
        Me.Requery

Posting Permissions

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