hi, i meant the first solution, but the second one is better now that i looked better to my needs. however i've already tried without success to loop through the excel column, i don't know how to define the range of the loop that should be the number of field in access table, but even if i count that, if fields are 20 in excel the column name is "T", i can't build a code that goes to "a" to "t", where "t" is the column number 20
however i tried this code
Code:
For Each Idx In Tbf.Indexes ' cerca tra i campi della tabella quali sono i primary key i = i + 1
If Idx.Primary Then
Fld = Idx.Fields
FldName = Idx.Fields 'ritorna il nome del campo primary key
MsgBox (Idx.Fields)
MsgBox (i)
Set Rst = db.OpenRecordset("SELECT " & TbEx & ".[Data/ora creazione], " & TbEx & ".[Data/ora modifica], " & TbEx & ".Autore, " & TbEx & ".[Modificato da] " & vbCrLf & _
"FROM " & TbEx & " INNER JOIN " & Tbf.Name & " ON " & TbEx & "." & FldName & " = " & Tbf.Name & " & FldName & " & vbCrLf & _
"WHERE (((" & TbEx & ".[Data/ora modifica])<[" & Tbf.Name & "].[Data/ora modifica]));") 'controllo se nella tabella che sto considerando al momento alcuni record hanno la data di modifica pił recente nel database che nel file excel/tabella collegata, per aggiornare i dati sorgente di powerapps
If Rst.RecordCount > 0 Then 'se ci sono record allora faccio l'update del
If Rst.BOF Or Rst.EOF Then
Rst.MoveFirst
' Do Until Rst.EOF
'
' Loop
End If
End If
End If
Next
i set i + 1 for every field loop, so if the second field is the primary should give 2, is it correct or it's a bad code?