form automatically saving records

Humberto

Registered User.
Local time
Today, 08:40
Joined
Jan 8, 2002
Messages
40
i have a form with textboxes that are linked to a table. my problem is that when I click on the previous record and when I get out of the form it automatically saves the record to the table. if I put the date as the index key it will give me an error that it cannot save changes that I made. Please help!!
 
Access saves the records as you move from one to another. If you do NOT want to do this, you need to consider hiding navigation, running code, etc. All depends on what you want TO DO on the form. Are you wanting to view records only? You could have the form open in read only. Edit records only? Open form with its AllowAdditions property set to NO.

About the index thing.....Access is throwing the error because somewhere you have set a primary key. What is the primary key of the table the form is based on? It seems you are using a date field for something. A date field would be unusual for a primary key, but I suppose there may be a data system where it could be used that way.
 
the form should be design to navigate through records, add, edit, and delete records, so the AllowAdditions and the navigation should be set to Yes. Is there a way to have the form do that without saving the last record too many different times if there is no index on the table that the form is linked to?? Help Needed!!!!!
 
when navigating through records, it automatically creates a new record and saves it in the table. Help!!!!
 
Is there something in your form which auto-populates certain fields when you enter a new record? If so, Access is considering that the same as data entry and saving the 'new' record.

David R
 
Yes, I think is the date field. I am using Date(), I'll try that!
 
yes, the problem was the date(), but I have the error 'Runtime error 3022' which happens when I try to save a record with a field that does not accept duplicates. How can I show a message box instead of that error? I need that field to be unique. thanks for the help!!!
 
Here's what I used to alleviate this error (which comes about when you try to duplicate your primary key):
Code:
Private Sub Participant_ID_BeforeUpdate(Cancel As Integer)
   If DCount("[ParticipantID]", "Participant", "[ParticipantID]= '" & Me![ParticipantID] & "'") = 1 Then
      MsgBox "This is a duplicate Participant ID."
      Me.Undo
      Cancel = True
   End If
End Sub

I believe there is a faster way to do this using recordsets instead of Dcount, if you have a LARGE number of records.


However, if you're getting this message automatically, I would try to find what is causing the alleged duplication. Is your date-type field unique? If someone moves twice between records in one second I suppose it could conceivably have the same value...

HTH,
David R
 

Users who are viewing this thread

Back
Top Bottom