Solved

Editing Record not updating in Access

Posted on 2016-08-26
4
39 Views
Last Modified: 2016-08-30
i made a search bar to look up a record to edit but when i do it only update the first record on the table and not the record iam searching for.  Thank you for the help and here an attachment of the database.
Incident-Report-Database---ASR.accdb
0
Comment
Question by:gsilouisvilleic
  • 2
4 Comments
 
LVL 34

Assisted Solution

by:PatHartman
PatHartman earned 100 total points
ID: 41771877
I'm not sure what you are trying to do but F_IncidentCloseForm is bound and so you don't need any of the code you have in savedata1.  All your save button needs to do is to force the save using -
DoCmd.RunCommand acCmdSaveRecord

The reason your code isn't actually updating the correct record is because you are opening a table and simply updating the first record returned in the recordset.  You would need to either open a query with selection criteria or open the table and use the Find method to find the record you want to update.

And one more point - ALWAYS disambiguate DAO objects because if you were to ever have to add a reference to the ADO library, your code would fail or work improperly.

So

Dim rs As DAO.Recordset

is the correct way to dm the object.

A better solution is to simply let Access do its thing.  If all you want the user to update is the Comments field, set the Locked property of all the other controls to Yes and set their tab stops to No so tabbing won't stop in those fields.  I also usually make the backgrounds transparent so the data entry controls show up more easily when not all controls on a form can be updated.  Using this method takes advantage of the power of bound forms and reduces your code to the single save line in the click event of the save button.

OK - one more point.  Column names should contain only the letters a-z and A-Z, the numbers 0-9 and the underscore.  Do not use embedded spaces or special characters.  I prefer to use CamelCase to form my names.  Others prefer the_underscore.
0
 
LVL 2

Expert Comment

by:Antonio Salva Ripoll
ID: 41772037
Hi  gsilouisvilleic.

As said @Pat, the table names, column names, form names... must not include spaces o other characters different than letters or numbers and underscore.

I prepared the sample you have posted, based on your original database.
I'll download your modified database, modify it to use CamelCase or underscores, and to accomplish what you are looking for.

Please, let me work on a solution during this weekend.

Best regards.

Antonio. ( Barcelona, Spain)
0
 
LVL 2

Accepted Solution

by:
Antonio Salva Ripoll earned 400 total points
ID: 41775071
This expert suggested creating a Gigs project.
Hi  gsilouisvilleic.

I've modified the database, now, the the T_Incident_Table table name and fields are CamelCase mixed with underscores, also I modified the form to use the new names.

First I used F_IncidentCloseForm modifying search form; but latern I thought maybe it would be better to teach you how to use a form for a dual purpose.

And this is what I do, now you have only the F_Incident_Form for the dual purpose, add new incidents and close them.

All this is done via VBA code, so, I think this will teach you how to do things.

Best regards.

Antonio.
Incident-Report-Database---ASR_1.accdb
0
 

Author Closing Comment

by:gsilouisvilleic
ID: 41775924
thank you so much guys
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now