i_n
i_n

Reputation: 25

The Microsoft Access database engine cannot find a record in the table 'Vlasnik' with key matching field(s) 'Narudzba.ID_VU

I have form "Nova narudzba" in which I enter data about customers and bought items. Problem is when I open that form and I try to close it without choosing customer from combobox [control source of that combobox is Narudzba.ID_VU and is 0 if I don't select any other customer from it] and then I get following popup window "The Microsoft Access database engine cannot find a record in the table 'Vlasnik' with key matching field(s) 'Narudzba.ID_VU".

So problem on closing form is that value of that combobox is 0 and there is no Vlasnik.ID_VU with 0 value.

Relationships

I guess solution would be to close form without saving data, but I don't know how to do that.

I tried this, but it is not working(I am getting popup with Run time error '2465' - MS Access can't find the field '|1' referred to in your expression:

If [Narudzba.ID_VU].Value = 0 Then
[Nova narudzba].Close savechanges:=False

Else
[Nova narudzba].Close
End If


End Sub

Upvotes: 0

Views: 1543

Answers (1)

i_n
i_n

Reputation: 25

When I click on Command81 (exit button) if Narudzba.ID_VU is 0 is exiting without saving and not giving warning, if it is not 0 form is saving entered data.

  Private Sub Command81_Click()

    If [Narudzba.ID_VU].Value = 0 Then
    DoCmd.Close acForm, "Nova narudzba", acSaveNo

    Else
    DoCmd.Close acForm, "Nova narudzba", acSaveYes
    End If


    End Sub

Upvotes: 0

Related Questions