Group:  Microsoft Access ยป microsoft.public.access.modulescoding
Thread: Programmatically create an Autonumber Field using FieldDef

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Programmatically create an Autonumber Field using FieldDef
"jeff" <jeff[ at ]work> 06.06.2006 05:48:42
Hi gurus!

I am using code to generate 2 related temporary tables. I want to use an
Autonumber field in the first which is used as the Foreign Key in the
second.

How do I create the field definition using the FieldDefs objects to be an
AutoNumber Field type. I can do the following:-


Set ltdfDestination = mDb.CreateTableDef("temptable1")
Set lfldDestination = ltdfDestination.CreateField("temptable1_id",
dbLong)
ltdfDestination.Fields.Append lfldDestination

I want to make the temptable1_id field an AutoNumber field.

Any ideas?

cheers
Jeff


Re: Programmatically create an Autonumber Field using FieldDef
"Allen Browne" <AllenBrowne[ at ]SeeSig.Invalid> 06.06.2006 07:05:02
An AutoNumber is a Long with the dbAutoIncrField attribute bit set.

Set the Attributes of the field before you Append it:
fld.Attributes = dbAutoIncrField + dbFixedField

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"jeff" <jeff[ at ]work> wrote in message
news:%23OxkmwSiGHA.3496[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> Hi gurus!
>
> I am using code to generate 2 related temporary tables. I want to use an
> Autonumber field in the first which is used as the Foreign Key in the
> second.
>
> How do I create the field definition using the FieldDefs objects to be an
> AutoNumber Field type. I can do the following:-
>
>
> Set ltdfDestination = mDb.CreateTableDef("temptable1")
> Set lfldDestination = ltdfDestination.CreateField("temptable1_id",
> dbLong)
> ltdfDestination.Fields.Append lfldDestination
>
> I want to make the temptable1_id field an AutoNumber field.


Re: Programmatically create an Autonumber Field using FieldDef
"david epsom dot com dot au" <david[ at ]epsomdotcomdotau> 06.06.2006 07:51:24
Set lfld = ltdfDestination.CreateField("temptable1_id", dbLong)

lfld.Attributes = dbAutoIncrField

ltdfDestination.Fields.Append lfldDestination

This attribute must be set before the field is appended

(david)


"jeff" <jeff[ at ]work> wrote in message
news:%23OxkmwSiGHA.3496[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> Hi gurus!
>
> I am using code to generate 2 related temporary tables. I want to use an
> Autonumber field in the first which is used as the Foreign Key in the
> second.
>
> How do I create the field definition using the FieldDefs objects to be an
> AutoNumber Field type. I can do the following:-
>
>
> Set ltdfDestination = mDb.CreateTableDef("temptable1")
> Set lfldDestination = ltdfDestination.CreateField("temptable1_id",
> dbLong)
> ltdfDestination.Fields.Append lfldDestination
>
> I want to make the temptable1_id field an AutoNumber field.
>
> Any ideas?
>
> cheers
> Jeff
>


Re: Programmatically create an Autonumber Field using FieldDef
"jeff" <jeff[ at ]work> 09.06.2006 01:09:34
Thanks to Allen and David for the helpful responses...cheers guys....its the
little things that help the most!


"jeff" <jeff[ at ]work> wrote in message
news:%23OxkmwSiGHA.3496[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> Hi gurus!
>
> I am using code to generate 2 related temporary tables. I want to use an
> Autonumber field in the first which is used as the Foreign Key in the
> second.
>
> How do I create the field definition using the FieldDefs objects to be an
> AutoNumber Field type. I can do the following:-
>
>
> Set ltdfDestination = mDb.CreateTableDef("temptable1")
> Set lfldDestination = ltdfDestination.CreateField("temptable1_id",
> dbLong)
> ltdfDestination.Fields.Append lfldDestination
>
> I want to make the temptable1_id field an AutoNumber field.
>
> Any ideas?
>
> cheers
> Jeff
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net