473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Existence of Field Name in Record Set

I did find reference to the question in a search of google groups, but
I couldn't find a clear answer.

I need, essentially,

if rs.Fields("X") exists Then _
do something

where rs is an ADO recordset and "X" is a particular fieldname

Is there an easy way to do this?

thanks, --thelma
Feb 14 '06 #1
3 4164
On 14 Feb 2006 02:30:31 GMT, Thelma Lubkin <th****@alpha2.csd.uwm.edu>
wrote:

Yes. I can think of two basic approaches: either iterate over the
Fields collection:
dim f as adodb.field
for each f in rs.Fields
if f.Name = strFieldNameToFind then
'etc.

or try to access a property of that field and handle the error
appropriately:
on error resume next
strName = rs.Fields(strFieldNameToFind).Name
if Err.Number = 0 then
'etc.

-Tom.

I did find reference to the question in a search of google groups, but
I couldn't find a clear answer.

I need, essentially,

if rs.Fields("X") exists Then _
do something

where rs is an ADO recordset and "X" is a particular fieldname

Is there an easy way to do this?

thanks, --thelma


Feb 14 '06 #2
On 14 Feb 2006 02:30:31 GMT, Thelma Lubkin <th****@alpha2.csd.uwm.edu> wrote:
I did find reference to the question in a search of google groups, but
I couldn't find a clear answer.

I need, essentially,

if rs.Fields("X") exists Then _
do something

where rs is an ADO recordset and "X" is a particular fieldname

Is there an easy way to do this?

thanks, --thelma


Try and read the value of .Fields("X"), it will throw error 3265 if the field
does not exist. Use an error handler to trap 3265 and do whatever if the error
is raised.
Wayne Gillespie
Gosford NSW Australia
Feb 14 '06 #3
Tom van Stiphout <no*************@cox.net> wrote:
: On 14 Feb 2006 02:30:31 GMT, Thelma Lubkin <th****@alpha2.csd.uwm.edu>
: wrote:

: Yes. I can think of two basic approaches: either iterate over the
: Fields collection:
: dim f as adodb.field
: for each f in rs.Fields
: if f.Name = strFieldNameToFind then
: 'etc.

: or try to access a property of that field and handle the error
: appropriately:
: on error resume next
: strName = rs.Fields(strFieldNameToFind).Name
: if Err.Number = 0 then
: 'etc.

Thanks to you and Wayne Gillepsie.
Right now I'm using the first method and finding it very
clumsy. I will see if I can make something more 'elegant'
out of throwing an error...
--thelma
: -Tom.
Feb 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thelma Lubkin | last post by:
How do I search for the existence of a field name in a table? I don't want to do this programmatically: I'm sitting at the screen, looking at the table's design view, and there are just too many...
3
by: Daron | last post by:
Is it possible to use a parameter as the field name, not just a criteria? Snippet of my SQL: SELECT Eval("!!.(0)") AS TestField, AS from qry_main The parameter will hold the name of the...
3
by: prabhukumarasamy | last post by:
Now i m working in a existing project. I have to do some updations. In that project database table contain a table(usergroups) field name as 'Name'. When i am trying to insert a new record in...
1
by: BobM | last post by:
i read the thread entitled "Convert Field Value String to Actual Field in Expression" It appeared that the final solutions got moore complex not less complex MY PROBLEM IS: 1. get a value from...
1
by: Ke0EE | last post by:
I am trying to use a record field date as the field name of a different table. Function SetChangeOnInactive() ' This routine will set the Closed Area change flag if someone with ' Open/Close...
4
by: BarryB | last post by:
I imported a large table of classes, teachers and students from Excel to MS Access. Up to a point, this worked out ok. Unfortunately, the students are represented as field names (Smith_Abigail,...
1
by: bassi.carlo | last post by:
I have an application with many combobox in different forms used for choose a particular length (for example items are "ft" - feet, "in" - inch, "m" - meters, and so on). I don't want to put in...
8
by: machoq | last post by:
Hi folks, I have a javascript object called record and i want to pass the field name dynamically. Something like print(record.$field) It always gives me null, what can i do so that it prints...
6
by: kpfunf | last post by:
Ok, I hope I can explain this one well enough! I have tables that contain similar data but are not all uniform; I use queries to create uniform data sets (same field names, formatting, etc.). I...
3
by: adiel_g | last post by:
Hello everyone, I am trying to move a field name to a variable in vb.net. For example, first I retrieve the record from the database and save its value: .... userGroup =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.