Weird SQL error

I have the following code which works fine as an SQL query but is giving me an error in Xojo when I try to compile: “Their are several items with this name and it is not clear which one the call refers to” on the data.Field line.

Dim sql As String Dim data As RecordSet Dim NumPatients as integer = 0 sql = "SELECT COUNT(ID) as NumPatients FROM cmpPatients WHERE AffiliateID='" + Session.pAffiliateProfile.ID + "' AND Hidden=0" data = DB.SQLSelect(sql) NumPatients = data.Field("NumPatients")

data.field returns a database field not a number
NumPatients = data.Field(“NumPatients”).IntegerValue

Of course, thanks Norman