I have those two tables is MS Access :
lkpSchemaPIT :
| UID | lkpSchemaTitleEng |
|-----|--------------------------|
|--1--|---------Title1-----------|
|--2--|---------Title2-----------|
...
lkpSchemaPITChronology :
| ID | UID | PUID | Sort | Level | DateStart | DateEnd |
|----|-----|------|------|-------|-----------|---------|
|--0-|--1--|--0---|---5--|--2----|---Now()---|--NULL---|
...
The first table contains just nodes that i'm going to put in a treeview in access. I use the second table to construct the tree, but also keep track of all the parent that a node could've had through the years. You can see that the UID in the two tables are the same, but they have not a relationship between them, when I build the tree, I use a query with a join on it.
My problem is : When I want to add a new node in the lkpSchemaPIT table, I need to be able to add its "treeview" info as well (Parent, Sort, Level, etc.).
This is my code so far :
With CurrentDb
.Execute _
"INSERT INTO lkpSchemaPIT " & _
"(lkpSchemaTitleEng) " & _
"VALUES " & _
"('" & Title & "')"
.Execute _
"INSERT INTO lkpSchemaPITChronology VALUES (" & .OpenRecordset("SELECT @@IDENTITY").Fields(0) & ", " & [ParentID] & ", " & [NewSort] & ", " & [Level] & ", " & Date & ", null)"
End With
ParentID, NewSort, Level are 3 variables that have been determined before I call all this. The "Date" parameters is the VBA function that returns the current date.
I know that the first INSERT INTO is working because a new value is displayed in my table. But the second INSERT INTO isn't working and I was able to get the error :
Error 3346 - Number of query values and destination fields are not the same.
Is anyone ever had this kind of problem ?