Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "SHAPE {Select distinct Orderin.Id as الرقم, Orderin.Indate as [تاريخ الأمر], Orderin.RefId as [المرجع], Orderin.Refdate as [تاريخ المرجع], " _
& "Orderin.Source as [الجهة الموردة], Orderin.Desc as [البيان], Orderin.PrintState as [Print], Orderin.UserId as المستخدم " _
& "From Orderin INNER JOIN Itemindetail ON Orderin.Id = Itemindetail.Id " + QryStMstr + " } AS ParentCMD APPEND ({Select Itemindetail.Id as الرقم,Itemindetail.ItemId as [كود الصنف], " _
& "Items.ItemDesc as [اسم الصنف], Itemindetail.Qty as [الكمية], Items.Unit as [الوحدة], Itemindetail.Qtychar as [الكمية بالحروف] " _
& "From Itemindetail,Items Where Items.Itemid=Itemindetail.Itemid Order by Itemindetail.ItemId} AS ChildCMD RELATE الرقم TO الرقم) AS ChildCMD", db, adOpenStatic, adLockOptimistic