Results 1 to 5 of 5
  1. #1
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101

    Delete fileds in tables by using sql statement

    Hello,

    I need to delete data in a table that named Cap One Table. I can not use a delete query since database located on company server and it is being used by many people. So, I have created a form and put on there two text boxes - txtStartDate and txtEndDate and command button cmdDelete. An idea behind this is that a user types date in txtStartDate and txtEndDate and click command button and delition happend in table Cap One based on that criteria. I put the below code in command button click event , but it doesn't work. Please, really apreciate and alot of thanks in advance if you help me with code:

    Dim startDate As String
    Dim EndDate As String
    Dim strSql As String
    startDate = txtStartDate.Value
    EndDate = txtEndtDate.Value




    strSql = "Delete Cap One.Date" & _
    "FROM Cap One" & _
    "WHERE (((Cap One.Date)>=#" & startDate & "# And (Cap One.Date)<=" & EndDate & "#"

    Thank you ,

    Best Regards,

    Borisgomel

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    If that's it, you never execute the SQL:

    CurrentDb.Execute strSql

    If you still have trouble, check the SQL:

    http://www.baldyweb.com/ImmediateWindow.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    By the, way, you realize that is a delete query?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    BorisGomel is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    Apr 2011
    Posts
    101
    Thank you very much Paul. I fugured out .Your link was very helpfull.
    Thanks a lot,
    BorisGomel

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Delete duplicates from both tables
    By dakpluto in forum Queries
    Replies: 2
    Last Post: 07-02-2012, 04:49 AM
  2. Delete tables if the exist
    By dumbledown in forum Programming
    Replies: 1
    Last Post: 03-29-2012, 04:49 AM
  3. Error: Could not delete from specified tables
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-03-2011, 02:07 PM
  4. Delete SQL statement not working properly
    By Alexandre Cote in forum Programming
    Replies: 3
    Last Post: 10-18-2010, 12:56 PM
  5. Could not delete from specified tables.
    By bullwinkle55423 in forum Queries
    Replies: 0
    Last Post: 08-31-2006, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums