you'll need to use some vba code to check for the existence of the field(s) and then dynamically build your query
perhaps something like
Code:
dim fld as DAO.field
dim sqlstr as string
sqlStr="SELECT [tblReferences].Cod, [tblReferences].Name"
for each fld in currentdb.tabledefs("name of your linked table").fields
if fld.name like "ref_" then sqlstr = sqlstr & ", nz(" & fld.name & ")"
next fld
sqlstr=sqlstr & " AS Ref_Total FROM [tblReferences] ORDER BY [tblReferences].Name;"
debug.print sqlstr 'to check it has been correctly created
currentdb.querydefs("name of your query").sql=sqlstr
'or if you have a form
forms!myform.recordsource=sqlstr
this is aircode so their may be typos but should get you on your way