
Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)
Doug,
Whereas setting Referential Integrity with Cascade Deletes enabled in
the Relationships Window is independent of libraries referenced, I
believe Rick is referring to running ALTER TABLE or CREATE TABLE
statements within VBA, and as such I believe this will not work with
DAO.
- Steve Schapel, Microsoft Access MVP
>??? Whether you use DAO or ADO is completely unrelated to how referential
>integrity works! Cascade Deletes are definitely supported in Access 97: I
>work almost exclusively in Access 97, and I'm capable of supporting them
>without any problems.
Douglas J. Steele - 26 Dec 2003 21:59 GMT
Thanks, Steve. I never use ALTER TABLE or CREATE TABLE, so you may be right.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)
> Doug,
>
[quoted text clipped - 8 lines]
> >work almost exclusively in Access 97, and I'm capable of supporting them
> >without any problems.
TC - 27 Dec 2003 03:39 GMT
The OP is thinking as follows: "I don't know how to do it from DAO,
therefore, it can't be possible from DAO".
Oops!
TC
> Thanks, Steve. I never use ALTER TABLE or CREATE TABLE, so you may be right.
>
[quoted text clipped - 15 lines]
> > >work almost exclusively in Access 97, and I'm capable of supporting them
> > >without any problems.
Rick Allison - 28 Dec 2003 21:30 GMT
Steve,
Thanks for clarifying. You are correct in what I want to do.
DAO does not support the "On Delete Cascade". I can write code to handle
the delete of data but why when Referential Integrity does that for you
automatically.
For me the solution is to write ADO. For now I have mixed ADO and DAO
because I still have not figured out how to manage the Default Value on an
existing column in a table via ADO (or ADOX, it that's the way).
Still looking.
Rick
> Doug,
>
[quoted text clipped - 10 lines]
> >work almost exclusively in Access 97, and I'm capable of supporting them
> >without any problems.
Douglas J. Steele - 29 Dec 2003 01:08 GMT
DAO may not allow you to specify "On Delete Cascade" in an ALTER TABLE or
CREATE TABLE statement, but you can still establish referential integrity
using DAO.
You do it by using the CreateRelation method, and setting the Attributes
parameter (the 4th parameter of the method) to dbRelationDeleteCascade.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)
> Steve,
>
[quoted text clipped - 26 lines]
> > >work almost exclusively in Access 97, and I'm capable of supporting them
> > >without any problems.
Rick Allison - 29 Dec 2003 02:28 GMT
Doug,
I cannot thank you enough for this. It would have taken me a long time to
find the CreateRelation method.
I'll be back to let you know how it goes.
Rick
> DAO may not allow you to specify "On Delete Cascade" in an ALTER TABLE or
> CREATE TABLE statement, but you can still establish referential integrity
[quoted text clipped - 36 lines]
> them
> > > >without any problems.
Rick Allison - 31 Dec 2003 18:03 GMT
Doug et. al.
What's the "db"Parameter to create an Autonumber field in a table?
I switched to TableDef to create tables on the fly but I cannot find how to
create an autonumber field. Best I can find is to create an integer then a
unique index (primary key) but that's it.
Thanks,
Rick
> DAO may not allow you to specify "On Delete Cascade" in an ALTER TABLE or
> CREATE TABLE statement, but you can still establish referential integrity
[quoted text clipped - 36 lines]
> them
> > > >without any problems.
Douglas J. Steele - 31 Dec 2003 19:38 GMT
You create the Field as dbLong, and then you set its Attributes to
dbAutoIncrField:
Set fld1 = tdf.CreateField("ContactID", dbLong)
fld1.Attributes = fld1.Attributes + dbAutoIncrField

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)
> Doug et. al.
>
[quoted text clipped - 51 lines]
> > them
> > > > >without any problems.
Rick Allison - 31 Dec 2003 21:03 GMT
Thanks again. This really helps. I am learning a lot!!
> You create the Field as dbLong, and then you set its Attributes to
> dbAutoIncrField:
[quoted text clipped - 64 lines]
> > > them
> > > > > >without any problems.