Results 1 to 7 of 7
  1. #1
    Access_Blaster is offline User
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2010
    Posts
    339

    DoCmd.RunSQL

    I have a list box that I can filter serial numbers with and it works great. Once the serial number is found and printed, I update the "printed" Boolean field with TRUE.


    Code:
    CurrentDb.Execute "UPDATE TblWalker SET Printed = true WHERE ID = " & Forms!FRM_SearchMulti!SearchResults.Column(0)
    How do I update the "Room" field at the same time? I can't get my code to insert into the filtered record, or the current record. It does however insert into a new record.
    Code:
    DoCmd.RunSQL ("INSERT INTO tblWalker ([room]) VALUES (room.value)")
    I want to use CurrentDb.Execute for this but no love either. Any help is appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Update as many fields of a record as desired. Is Room a number type field? Where is the room value come from?

    CurrentDb.Execute "UPDATE TblWalker SET Printed = true, Room = " & Me.room & " WHERE ID = " & Me.SearchResults

    Are Printed and Room fields included in the form RecordSource? If so, there is no need for the UPDATE sql action.

    Set values of fields of current record with:

    Me!Printed = True
    Me!Room = some input here
    Last edited by June7; 07-23-2013 at 01:35 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Access_Blaster is offline User
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2010
    Posts
    339
    June thanks for the response, this is a list box so me!printed doesn't work because the form is unbound with a list box control. The code in green works great, but I need an input box to put a variable in. The room is text but the input could be 201 or Main office, the Printed field will always be true if printed. This needs to happen while I have the filtered record visible in my list box.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    So you have solution with the multi-field UPDATE sql action?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Access_Blaster is offline User
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2010
    Posts
    339
    Quote Originally Posted by June7 View Post
    So you have solution with the multi-field UPDATE sql action?
    I need to use a input box to update the room field. Any suggestions?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Maybe a textbox or combobox on the form next to the listbox?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Access_Blaster is offline User
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2010
    Posts
    339
    Thank you figured it out.

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

Similar Threads

  1. problem with my DoCmd.RunSQL statement
    By cgclower in forum Access
    Replies: 1
    Last Post: 07-24-2011, 06:12 PM
  2. my first DoCmd.RunSQL
    By broecher in forum Programming
    Replies: 4
    Last Post: 11-05-2010, 09:35 PM
  3. docmd.runsql update
    By Mitch_Aus in forum Programming
    Replies: 2
    Last Post: 10-05-2010, 09:45 AM
  4. Problem with DoCmd.RunSQL
    By Peter01 in forum Programming
    Replies: 2
    Last Post: 09-10-2009, 07:11 PM
  5. docmd.runsql not working
    By Rameez in forum Programming
    Replies: 3
    Last Post: 08-07-2009, 10:07 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