Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to check if a field name exists in recordset 3

Status
Not open for further replies.

SweetDot

Technical User
Jan 19, 2004
65
US
Hi,
is there any easy way to check if a field name exists in a recordset without having to iterate through the entire list of field names?

thanks very much
 
I don't think so. You could though try do a Select FieldName_X from YourTable and trap for the error you're gonna get when doesn't exist.
 
icic, thanks
i think i'll just stick to iterating through the list then. might be too much trouble searching for the error trapping syntax.
thanks a lot
 
Hi SweetDot,

It isn't really that difficult, but it does involve error trapping ..

Code:
On Error Resume Next
Set fld =
Code:
RecordSet
Code:
.Fields("
Code:
FieldName
Code:
")
On Error Goto 0

If fld is Nothing Then
Code:
    ' Field does NOT exist
Code:
Else
Code:
    ' It does
Code:
End If

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
thank you so much. that's much easier than i thought it would be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top