Simple Form question: How to update, not append

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a simple table with one record (one row) like this:
MyValue | MyBool
123 | True

The columns MyValue and MyBool are linked to a form, in which i want to
change them. The problem is: When I run the form and check MyBool, then it
appends a new row to my table. How can I tell it to update the existing row
instead?
 
If you are using a form, you can set the AllowAdditions property to false,
either manually or in code. Typically, you would use the property sheet to
set it to False, then code a button to add a new record like (aircode):

Sub cmdNew_Click()
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Does your Form use the Table (or a Query based on the Table) as the
RecordSource for the Form?

If you do and you have only 1 Record, this Record should be the current
Record (you can only edit the CurrentRecord on the Form) when you open the
Form. If a new Record appears when you open the Form, you may have set the
"Data Entry" Property to Yes / True.

Open the Form in DesignView, open the Properties window of the Form. In the
Data tab, set:

Allow Edits to Yes / True
Allow Deletions to No / False
Allow Additions to No / False
Data Entry to No / False

This way, the Form will open with your only Record as the CurrentRecord and
you can edit it but it cannot be deleted no new Records can be added.
 
Thank you - that's what I expected, too, but for some reason Access doesn't
listen to the AllowAdditions property. It still happily appends. Even when I
set the MyValue field as primary key, it still tries to append (and fails of
course because it would duplicate the key).
 
Thank you, that, too, is exactly what I had. (Sorry, I should have provided
the list of all properties to spare you these iterations. I just found out
that this can be done with the Documenter.)
2 settings that are a bit unusual are:
Record Selectors = No
Navigation Buttons = No
I set them both to Yes and it worked. Then I wanted to find out which of
them made the difference, and now it works again, even when both are set to
No. Weird! Maybe it has to do with the fact that the DB is in Access 2000
format?

Anyway, I'm happy now; and if it occurs again I'll just wiggle the
properties back and forth again.

Sebastian
 
The original Access 2000 was bugsy but I found since SR-1a, Access 2000 is
quite OK.

You should make sure you apply all SRs / SPs to both Oaacess / Office and
thew Windows OS.
 
Back
Top