MaxMadneSS
New member
- Local time
- Today, 10:42
- Joined
- Jul 4, 2016
- Messages
- 7
I have 2 input forms and they are connected with 1-1 relation (enforced referential integrity checked).
The point is to add data in main Form then click button to open next Form and add data there as well.
But once I add data to second Form, and they are obviously related to data in main Form, I can no longer edit them in main Form. I can edit other data that has no match in second Form which means the code is working.
This is how tables look like:
(close enough
)
And the code that is adding data to table looks like this
Option 2 is obviously not working when there is relation or match in both Forms (or tables if you like).
I would really like to know how to fix this and what exactly is causing this problem.
Note: Altho I can remove primary keys and referential integrity which makes everything work like its supposed to, in which case I would just need more checks and coding in Form to avoid double entry's and similar things.
EDIT: I missed to say that the code in Option 2 is working I debugged it and all the data is there everything is good but when you click Edit button nothing changes.
I get no error just like everything is ok, but all the data remain same as before editing.
The point is to add data in main Form then click button to open next Form and add data there as well.
But once I add data to second Form, and they are obviously related to data in main Form, I can no longer edit them in main Form. I can edit other data that has no match in second Form which means the code is working.
This is how tables look like:
(close enough

Code:
[B][U]tblPIO[/U][/B] [B] [U] tblPosmrtnina[/U][/B]
#ID ------------ 1-1 ---------- #IDPosmrtnina
Name 2016
LastName 2015
... ...
... ...
Code:
[COLOR=SeaGreen]'cmdAdd has 2 options
'1. adding new entry
'2.editing existing data[/COLOR]
If Me.cmbID.Tag & "" = "" Then
[COLOR=SeaGreen]'option 1[/COLOR]
CurrentDb.Execute "INSERT INTO PIO(ID, Ime, Prezime, JMBG, Adresa, [Broj Adrese],[Fiksni telefon], [Mobilni telefon], [Mesna zajednica], [Opština],[Penzija]," & _
" [e-mail], [Beleške], [Preminuo], [Strana penzija])" & _
" VALUES (" & Me.cmbID & ",'" & Me.cmbIme & "','" & Me.cmbPrezime & "','" & Me.txtJMBG & "','" & Me.cmbAdresa & "','" & Me.txtBr & "','" & Me.txtFiksni & "','" & _
Me.txtMobilni & "','" & Me.cmbMesnaZajednica & "','" & Me.cmbOpstina & "','" & Me.txtPenzija & "','" & Me.txtEmail & "','" & Me.txtBeleske & "','" & Me.chkPreminuo & "','" & Me.chkPenzija & "')"
Else
[COLOR=SeaGreen]'option 2[/COLOR]
CurrentDb.Execute "UPDATE PIO " & _
" SET ID = '" & Me.cmbID & "', Ime = '" & Me.cmbIme & "', Prezime = '" & Me.cmbPrezime & "', Adresa = '" & Me.cmbAdresa & "'" & _
", [Broj Adrese] = '" & Me.txtBr & "', JMBG = '" & Me.txtJMBG & "', [Fiksni telefon] = '" & Me.txtFiksni & "'" & _
", [Mobilni telefon] = '" & Me.txtMobilni & "', [e-mail] = '" & Me.txtEmail & "', Opština = '" & Me.cmbOpstina & "'" & _
", [Mesna zajednica] = '" & Me.cmbMesnaZajednica & "', Penzija = '" & Me.txtPenzija & "', [Strana Penzija] = '" & Me.chkPenzija & "'" & _
", Preminuo = '" & Me.chkPreminuo & "', Beleške = '" & Me.txtBeleske & "'" & _
" Where ID = " & Me.cmbID.Tag
End If
cmdClear_Click
frmPIOSub.Form.Requery
I would really like to know how to fix this and what exactly is causing this problem.
Note: Altho I can remove primary keys and referential integrity which makes everything work like its supposed to, in which case I would just need more checks and coding in Form to avoid double entry's and similar things.
EDIT: I missed to say that the code in Option 2 is working I debugged it and all the data is there everything is good but when you click Edit button nothing changes.
I get no error just like everything is ok, but all the data remain same as before editing.
Last edited: