Results 1 to 4 of 4

Cant execute a update querry

  1. #1
    Fairportjay is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2019
    Posts
    9

    Cant execute a update querry

    I am trying to run an update querry that combines two fields from my Database. I am doing it this way as its only way I can figure out how to validate the entries in the form. here is my code . I am getting an error my querry can't be found but I know its saved as I can run it outside my form. is this a limitation of access? Thanks in advance for help

    Private Sub Form_AfterUpdate()


    Dim dbs As DAO.Database
    Dim lngRowsAffected As Long
    Dim lngRowsDeleted As Long
    Set dbs = CurrentDb
    ' Execute runs both saved queries and SQL strings
    dbs.Execute updatevalfield, dbFailOnError
    ' Get the number of rows affected by the Action query.
    ' You can display this to the user, store it in a table, or trigger an action
    ' if an unexpected number (e.g. 0 rows when you expect > 0).
    lngRowsAffected = dbs.RecordsAffected

    dbs.Execute "DELETE FROM tblMyTable WHERE Bad", dbFailOnError
    lngRowsDeleted = dbs.RecordsAffected

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    19,996
    The query name is a string argument. Try:

    dbs.Execute "updatevalfield", dbFailOnError

    I assume Bad is a Yes/No field?
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  3. #3
    Fairportjay is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2019
    Posts
    9
    Always something simple... thanks so much

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

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

Similar Threads

  1. Update Querry
    By Daryl2106 in forum Access
    Replies: 6
    Last Post: 08-29-2013, 11:09 AM
  2. Problems with CurrentDb.Execute "UPDATE
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 04-06-2013, 03:21 PM
  3. Update sql using currentdb.execute
    By laavista in forum Access
    Replies: 13
    Last Post: 08-15-2011, 03:51 PM
  4. update querry Problem
    By newtoAccess in forum Queries
    Replies: 1
    Last Post: 04-04-2011, 09:33 AM
  5. Update Querry
    By wrenchman123 in forum Queries
    Replies: 0
    Last Post: 02-05-2011, 07:21 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
  •  
Tech Forums: Microsoft Office Forums