Sorry people I'm not a friend of the domain functionality for obvious reason, slow performance especially against MS SQL Server, now the objectives are almost achieved through the help from this forum I'm now able to enter data in the parent table & child table at the same time and link the foreign key by using the DLAST function which I'm not comfortable with . Any idea to replace the Dlast function below, see VBA code :
Code:
Option Compare Database
Option Explicit
Private Sub CmdJson_Click()
Dim http As Object, JSON As Object, i As Integer
Dim item As Variant
Dim Z As Integer
Dim Y As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rst As DAO.Recordset
Set db = CurrentDb
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "http://jsonplaceholder.typicode.com/users", False
http.Send
Set rst = db.OpenRecordset("tblCustomerInvoice", dbOpenDynaset, dbSeeChanges)
Y = 0
rst.AddNew
rst("SalesDate") = Date
rst("InvoiceNumber") = "154696"
rst.Update
Y = Y + 0
MsgBox ("completed Invoice Header")
Set rs = db.OpenRecordset("tblInvoiceDeatils", dbOpenDynaset, dbSeeChanges)
Set JSON = ParseJson(http.responseText)
'i = 2
For Each item In JSON
'Process data.
Z = 1
rs.AddNew
rs("Id") = item("id")
rs("FirstName") = item("name")
rs("username") = item("username")
rs("email") = item("email")
rs("street") = item("address")("street")
rs("suite") = item("address")("suite")
rs("city") = item("address")("city")
rs("zipcode") = item("address")("zipcode")
rs("lat") = item("address")("geo")("lat")
rs("lng") = item("address")("geo")("lng")
rs("phone") = item("phone")
rs("WebSite") = item("website")
rs("catchPhrase") = item("company")("catchPhrase")
rs("Sname") = item("company")("name")
rs("bs") = item("company")("bs")
rs("InvoiceID") = DLast("InvoiceID", "tblCustomerInvoice")
rs.Update
Z = Z + 1
Next
MsgBox ("completed Invoice Deatils")
rs.Close
rst.Close
Set rst = Nothing
Set rs = Nothing
Set db = Nothing
Set JSON = Nothing
Set item = Nothing
End Sub