The following code fragment shows how code in the GetIdField function loops through the fields in the recordset and identifies the most likely primary key field by its type attribute, adFldFixed:
For Each oField In oRs.Fields
If oField.Attributes = adFldFixed Then
Set GetIDField = oField