access 2007 double record save

ripp3r

Registered User.
Local time
Today, 09:09
Joined
Apr 9, 2009
Messages
11
Hi all

I've a mask with some fields that rappresents a table.

I put a button with this VBA code:

Private Sub Command21_Click()

Dim rstPersone As DAO.Recordset
Dim dbinterventi As Object
Set dbinterventi = CurrentDb
Set rstPersone = dbinterventi.OpenRecordset("tab_Persone")

rstPersone.AddNew
rstPersone!Azienda = Azienda

If Azienda = True Then
rstPersone!Nome_azienda = Nome_azienda
Else
rstPersone!Nome = Nome
rstPersone!Cognome = Cognome
End If

rstPersone!Luogo = Luogo
rstPersone!Via = Via
rstPersone!Telefono = Telefono
rstPersone!Natel = Natel
rstPersone!Email = Email
rstPersone!Note = Note

rstPersone.Update

rstPersone.Close
Set rstPersone = Nothing

End Sub


Now, when I click this button, the current record is saved, but when I close my form (mask) or I change record or I add another one, access saves another record (THAT IS THE SAME OF THE ONE SAVED BEFORE) but with another ID.


I hope u understand.


Any suggestions?

Thanks
 
It sounds like the form is bound to the same table.
 
It sounds like the form is bound to the same table.

Damn... I'm sooo stupid

I created a form with the wizard -.- so it was associated with that table.

I created another form but with the Design and it works perfectly


Anyway, thanks :)
 
No problem; welcome to the site by the way!
 

Users who are viewing this thread

Back
Top Bottom