Results 1 to 6 of 6
  1. #1
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55

    Delete Row in Table from a Form

    Hello Im trying to get my code to work for deleting a row in a table from what is typed in a Text box on a Form. Im using a Button and a On Click Event.

    Details:
    Table name = ToolBoardKitNumT
    Primary Field Name = ToolBoardKitNum
    Form Name = AddToolBoardF
    TextBox Name = ToolBoardKitNum (the Control Source for this box is ToolBoardKitNum Field in ToolBoardKitNumT Table)



    Code:
    Dim strSQL As String
    'Delete record that was created but no longer needed
    strSQL = "DELETE * FROM ToolBoardKitNumT WHERE ToolBoardKitNumT.ToolboardKitNum = Me.ToolBoardKitNum"
    DoCmd.RunSQL strSQL
    When i Click on the Button I get a "enter parameter value" Box for "Me.ToolBoardKitNum". I know im getting this pop up because it does not know what "me.ToolBoardKitNum" value is but i dont know how to make it so it works.

    I want to Delete this Record from the table and not store it for later use. if they are clicking this button its because they entered this record incorrectly or the tool board is being deleted.

    any ideas?

    Thanks

    Munroe

  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,652
    strSQL = "DELETE * FROM ToolBoardKitNumT WHERE ToolBoardKitNumT.ToolboardKitNum = " & Me.ToolBoardKitNum
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55
    Quote Originally Posted by pbaldy View Post
    strSQL = "DELETE * FROM ToolBoardKitNumT WHERE ToolBoardKitNumT.ToolboardKitNum = " & Me.ToolBoardKitNum
    This Works But now I get a new "enter parameter value" for "AF". The Tool Boards we use are named using this format AF-001, AF-002... I think the "-" is creating a problem is there anyway around this?

    Thanks for the quick reply

    Munroe

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    For text values you need delimiters:

    strSQL = "DELETE * FROM ToolBoardKitNumT WHERE ToolBoardKitNumT.ToolboardKitNum = '" & Me.ToolBoardKitNum & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55
    Quote Originally Posted by pbaldy View Post
    For text values you need delimiters:

    strSQL = "DELETE * FROM ToolBoardKitNumT WHERE ToolBoardKitNumT.ToolboardKitNum = '" & Me.ToolBoardKitNum & "'"
    That worked like a dream!

    Thanks

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    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 does not delete records in evey table
    By LaughingBull in forum Access
    Replies: 5
    Last Post: 09-01-2015, 04:05 PM
  2. Replies: 1
    Last Post: 04-08-2015, 06:35 PM
  3. Replies: 9
    Last Post: 02-12-2015, 06:49 AM
  4. Replies: 1
    Last Post: 10-22-2013, 06:48 AM
  5. Replies: 2
    Last Post: 01-24-2012, 02:16 PM

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