"Field exists" syntax?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm sure there's some simple syntax for this, but as is too often the case, I
can't find it in the help...

I have to test whether or not a particular rowset has a field. The same code
might be called on any one of a number of tables, half of which have a field
called "entrydate". Is there some way to easily test to see if "entrydate"
exists? If I don't test, UPDATEs fail when I set it.

Maury
 
To see if the field exists, you can open the recordset, then try to hit the
field. If an error returns then it doesn't exist.

on error resume next
varTest = rs.fields("Fieldname").value
if error <> 0 then
'Field doesn't exist
else
'field does exist
endif
on error goto 0
 
To see if the field exists, you can open the recordset, then try to hit the
field. If an error returns then it doesn't exist.

There's no easier way?! This strikes me as astonishingly bizantine.
 
There's no easier way?! This strikes me as astonishingly bizantine.

If you're using the Execute method on a querydef object, with
dbFailOnError as a parameter (or with the Fail On Error property of
the query set to true), you can just trap the error there.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top