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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifying an Identity field

Status
Not open for further replies.

LeonAtRC

Programmer
Nov 25, 2002
101
0
0
US
I'm importing text files that were exported from Access. Some included the identity field and some did not. So I need to know which files have identity fields in them.
(The text files do not have all the fields that are in the SQL tables.)
Code:
Dim cnn as new adodb.connection
Dim rs as new adodb.recordset
Dim fld As Field

set cnn = currentproject.connection
rs.open "MyTable", cnn, adOpenForwardOnly, adLockReadOnly

For each fld in rs.fields
    if fld.Identity then
        docmd.runsql "SET IDENTITY_INSERT MyTable ON"
    end if
next
...
The problem with this code is that the field type does not have a property called "Identity"
Can someone suggest another way of determining, in Access, if a particular field is an identity field?
Thank you
Leon
 
Just a quick question, though doesnt answer your one specifically.
Why do you need to only run it for tables with an Identity column. Run it for all them and that way it doesnt matter about checking it, it should run regardless of there being an identity?

"I'm living so far beyond my income that we may almost be said to be living apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top