[AccessD] Question about the TableDef.Fields collection

Arthur Fuller fuller.artful at gmail.com
Fri Aug 26 16:07:08 CDT 2022


Thanks, Jim. That will help in the tool I'm building. I think the beta will
be done this weekend.

On Fri, Aug 26, 2022 at 11:56 AM Jim Dettman via AccessD <
accessd at databaseadvisors.com> wrote:

> Arthur,
>
> << But in tables containing no AutoNumber field, is there a Field attribute
> that identifies the PK of the table of interest?>>
>
>  The only attribute to indicate that a field is the "PrimaryKey" in Access
> is that it is a field in the index for the table which has the PrimaryKey
> property set to True.   The index is also name "PrimaryKey"
>
> ? CurrentDB().TableDefs("Table1").Indexes(0).Name
> PrimaryKey
>
> ? CurrentDB().TableDefs("Table1").Indexes(0).Primary
> True
>
> ? CurrentDB().TableDefs("Table1").Indexes(0).Fields(0).Name
> ID1
>
>
> Jim.
>
> -----Original Message-----
> From: AccessD On Behalf Of Arthur Fuller
> Sent: Friday, August 26, 2022 9:46 AM
> To: Access Developers discussion and problem solving
> <accessd at databaseadvisors.com>
> Subject: [AccessD] Question about the TableDef.Fields collection
>
> Like most Access programmers, I use AutoNumber fields as Primary Keys
> whenever it makes sense. However, it doesn't always make sense, and this is
> particularly so when the table of interest contains a relatively small
> number of rows. The reason I say this is because using an AutoNumber as the
> PK demands additional logic, to prevent otherwise equal rows from being
> added. For example, in a table of Countries, using an AutoNumber as the PK
> does not prevent the addition of country names that would duplicate an
> existing row. You could add Israel a dozen times, with each row having an
> AutoNumber. That said, I can think of no reason to have an AutoNumber in a
> table unless it is the PK.
>
> But in tables containing no AutoNumber field, is there a Field attribute
> that identifies the PK of the table of interest?
>
> Thanks in advance.
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
Arthur


More information about the AccessD mailing list