Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62

    Updating current record


    Code:
    Dim db As DAO.Database
        Dim rs As DAO.Recordset
        Set db = CurrentDb
        Set rs = db.OpenRecordset("Complaint", dbOpenDynaset)
        
        rs.FindFirst "[C01] = C01"
        
        If rs.NoMatch Then
            MsgBox "No match."
        End If
        
        rs.Edit
        rs!C02 = Me.C02
        rs.Update
    I find the record, and then try to update a field. The drop down menu field gets updated after it is initially changed from blank to a value, but it never changes after that though the re!C02 field has the correct newer data when I change it again.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Do not understand what you are doing.

    Why are you using a recordset to edit data? How is this related to a 'drop down menu' (combobox?)? "Never changes after that" means what - when moving to another record?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    I have a form that as a person updates a field the data in the table needs to be updated as well. For this field it just happens to be a combo box. I am aware that I could just use a button to save any updates that are made in the form but in this case it needs to be done as the person updates any of the fields on the fly. The correct data is in rs!C02 before rs.Update. It simply isn't updating the changed data. So, I change the data in a field, Access understands the data has been changed, and processes the data correctly until the actual update happens.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You should probably have something like this for your record validation.

    If rs.NoMatch = false Then
    rs.Edit
    rs!C02 = Me.C02
    rs.Update
    End If

    Not that it is going to fix the problem you are experiencing. Why not just assign a bound control to your combobox's control source?

  5. #5
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    It is a bound control. If I change the data in the field, it doesn't change it in the actual table. If that can be done without forcing it then I would like to know how. I looked at all of the properties, and I don't see anything that is off.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If a control on a form is bound then it should update the associated field in the table. The exceptions are, properties for the form or control that are set to not allow edits or the form's recordsource is based on a query that is not updateable.

  7. #7
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    The only one I have a question about would be a query not being updateable. How would I know and where to fix it? I do have a form where the user can search for a record and then update it but for some reason it deletes the record instead. I just went and retried putting in a new record and the data doesn't show up in the table. Again, if I tabbed past the last tab index and let Access clear the record then the data gets saved but that isn't what I am looking for. I am looking to enter in data and have it update the record as data is entered into the fields. The form and fields looked to be all editable allowing inserts, edits, deletes, etc.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If you open the query in datasheet view and you can edit the records then it is updatable. Sometimes not all of the fields are updatable. Sometimes you can not create new records. It depends on how you create the query and if you use Access to create relationship constraints such as Referential Integrety

  9. #9
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    I use the drop down menu on the record source to view the query builder and then select datasheet view and all of the fields can be edited, and I can add a record.

  10. #10
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    P.S. When I go in and act like I'm adding a new record in, a blank one is created.

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Not understanding why you can not update a record. If you want to upload your DB I will take a look at it. Be sure to mention the name of the form that is causing trouble. Remove private data and zip file down.

  12. #12
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    I tried to upload it, and the file after being zipped is 2.49MB and hence too big. I can upload it to my site when I get home.

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Remove some of the data and some of the objects before zip

  14. #14
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    I stripped it down as much as I could, and it made little difference. There's three forms. The frmComplaint is where a person can file a complaint. searchFrmComplaint is where a person can search for any complaint and resFrmComplaint is where the results of the search are shown. frmComplaint is obviously where a user can add to the database, and the search results is where a person can update a record after it is found. There are more forms that do similar things outside of complaints, but I figure if I can get this one working the others should fall into place as the issue is consistent across all of them. Again, I should be able to open the form, enter data, close the form, and then see the data in the table. I should then be able to search for the record and update it, close out the form, and see the new results in the table. If I try to enter in a new record, all I get is a blank one.

    http://www.matthewshanebrown.com/me/GrievanceB.zip

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    I ran Compact & Repair on your db and it went from 4992 KB to 780 KB.

    Field names like C01 ... C151 not informative. That's a LOT of fields in one table.

    Multiple Yes/No fields makes me think structure is not normalized.

    Why have 3 identical forms, one of which has unbound controls? They are all set for DataEntry Yes but resFrmComplaint has AllowAdditions set to No.

    I have no problem entering and editing records.
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Updating current Access Dbase
    By berger01 in forum Database Design
    Replies: 4
    Last Post: 06-28-2013, 01:35 PM
  2. Replies: 16
    Last Post: 02-06-2013, 03:06 PM
  3. Replies: 6
    Last Post: 12-11-2012, 09:40 PM
  4. Replies: 3
    Last Post: 09-19-2012, 07:34 AM
  5. Replies: 5
    Last Post: 08-24-2012, 10:32 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