Hello,
I have two table. A person (table1) make more exame (table2). This is a relation 1:n (table1:table2).
Table1: ID_1, name
Table2: ID_2, exame , ID_1
I create a mask in which i want to insert the data of table1 and table2. With a button I save them.
Table1: ID_1, NOME ---> id insert automatily, txt_nome
Table2: ID_2, dati, ID_1 ---> id insert automatily, txt_dati, i want the id of the table1
The first 'insert' insert the data right, but the second doesn't work.
The error is THE function id_r.Fields doen't defined in the expression.
What's the problem?
Thanks
I have two table. A person (table1) make more exame (table2). This is a relation 1:n (table1:table2).
Table1: ID_1, name
Table2: ID_2, exame , ID_1
I create a mask in which i want to insert the data of table1 and table2. With a button I save them.
Table1: ID_1, NOME ---> id insert automatily, txt_nome
Table2: ID_2, dati, ID_1 ---> id insert automatily, txt_dati, i want the id of the table1
Code:
[FONT=Courier New]Private Sub btn_Salva()
CurrentDb.Execute "INSERT INTO Tabella1 (NOME) VALUES (' " & Me.txt_nome & " ')
If Me.txt_dati <> "" Then
Dim id_r As DAO.Recordset
Set id_r = CurrentDb.OpenRecordset(" SELECT ID_1 FROM Tabella1 WHERE NOME = ' " & Me.txt_nome & " ' ")
CurrentDb.Execute "INSERT INTO Tabella2 (dati) VALUES (id_r.Fields(0), ' " & Me.txt_dati & " ')
End if
End sub[/FONT]
The error is THE function id_r.Fields doen't defined in the expression.
What's the problem?
Thanks