Results 1 to 3 of 3
  1. #1
    Dominaz is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    21

    Compare every record of a table with some form values

    Hello,
    I've a Form with some Data, that I want to use to change the records of a table.
    I mean I want the user to be able to input some data in a Form, eg. Subject, Year, City. I want to compare this data with some data in a table, and change the value of a field of each record.
    I know how to do it, using an Auxiliary Form, I use >
    ----------
    Do While Not IsNull(IdEmpleado) And Not Forms!Teachers!IdEmpleado Like "*(Autonumber)*"

    ............. I compare one by one and change...

    DoCmd.GoToRecord , , acNext

    Loop

    ------------- This code WORKS perfectly, but I want to use a faster method, but It doesn't work>


    So I tried the following method :

    Set db = CurrentDb()
    Set rst = db.OpenRecordset("Teachersform")





    Do While Not rst.EOF
    '........ Here I compare the fields and change the one I want

    rst.MoveNext
    Loop


    rst.Close

    And now It doesn't work, the following error appears:


    Update or CancelUpdate without AddNew or Edit




    What should I do???

    Thanks!!!
    Last edited by Dominaz; 12-19-2011 at 10:49 AM. Reason: Additional info

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    So, if the values to be replaced are all the same (in the form that is) and the test for which record to update is the same, why not just use an Update query? That is way more efficient.

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Use an update query - DoCmd.RunSQL "...."

    Use the information that is on the form such as "WHERE [xxxx]='" & me![xxx] & "' etc

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

Similar Threads

  1. Replies: 3
    Last Post: 11-23-2011, 12:25 AM
  2. Create Query to Compare Values
    By shannon9585 in forum Queries
    Replies: 4
    Last Post: 12-29-2010, 05:55 PM
  3. Replies: 1
    Last Post: 06-24-2010, 08:08 AM
  4. Replies: 3
    Last Post: 04-04-2010, 05:26 PM
  5. Replies: 0
    Last Post: 08-01-2009, 12:43 PM

Tags for this Thread

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