Reputation: 2291
I have a recordset. And I want to know if a field with name MyField exists.
How to find out if a field exists?
while not oRs.eof
if oRs.Fields("MyField").Exists = true and oRs("MyField") then
' Result is true
end if
oRs.movenext
wend
Yrs Sincerly
Upvotes: 0
Views: 860
Reputation: 175826
You will need a helper function to iterate the fields and compare;
dim exists: exists = ContainsField(oRs, "MyField")
while not oRs.eof
if exists ...
Using
function ContainsField(rs, name)
dim fld
name = UCase$(name)
for each fld in rs.Fields
if UCase$(fld.name) = name then
ContainsField = true
Exit Function
end if
next
ContainsField = False
End function
Upvotes: 3