السلام عليكم
المشكلة ان امر
SetOrderBy
لا يقوم فعليا بترتيب البينات عند استخدام متغير
Field1
بدلا من اسم الحقل
وكذك في المثال الثاني لا يقبل الامر
order by " & Field1
'-----------------------------------------------------------------
Field1 = Table_2.Fields(2).Name 'for example Filed(2) is "Age"
DoCmd.SetOrderBy Field1 ' Here VBA accept this code line but acutally not sort the table by Filed(2)="Age".
Table_2.Fields.Item(Name).Value = Table_1!Name 'Here it copy orginal first record, not record after sorting (i.e Name filed)
Next I
' Here I try other way to sort
' But Also VBA not accept below statment
Table_1.Open "select * from Table_1 order by " & Field1, , adOpenKeyset, adLockOptimisti