Re: What does this mean?
- From: Freehal04 <Freehal04@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 16 Jan 2007 10:01:01 -0800
Alright,
I previously had the table wizard annylize my tables and it cut it into the
two tables I have now and it would see to have my one to many relationship
with the many side on the table I wanted to be the parent. I'm not sure how
this happened. I'm still new to this. I think this might affect the code
you gave me. But, I input your code and it deletes, but it deletes ALL my
records, not just the one displayed on the form.
I reversed the parent child coding hoping it would compensate for the
problem I just told you about but it doesn't seem to work. RI is enforced
but cascade update and delete are not. Is there a way to fix this? If you
need more info about my DB let me know.
Thanks.
"tina" wrote:
well, you're not telling us anything about those two tables used in the.
query. i'll assume that Table1 is the parent table, and i'll call the
primary key field ParentID. i'll assume that Table2 is the child table, and
i'll call the foreign key field (that links it to Table1) Child_ParentID.
if your relationships are set properly in the Relationships window, with
referential integrity enforced, then you'll have to delete the Child
record(s) before you can delete the parent record. try the following on a
COPY of your database, as
Dim lng As Long
lng = Me!ParentID
CurrentDb.Execute "DELETE * FROM Table2 WHERE " _
& "Child_ParentID = " lng, dbFailOnError
CurrentDb.Execute "DELETE * FROM Table1 WHERE " _
& "ParentID = " & lng, dbFailOnError
Me.Requery
the above code assumes that the primary/foreign key fields are Number data
type with Field Size as Long Integer, or AutoNumber (which is also a long
integer).
hth
"Freehal04" <Freehal04@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2C0A0BBF-A2B3-4859-A97D-A35872A1FFB2@xxxxxxxxxxxxxxxx
I added a delete button to my form that is based on a query. The query ison
based on two tables. The delete button only deletes info for the record
only one of the tables. The SQL expression read this way:on
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Damian S told me to use this:
docmd.runsql "delete from TABLE1 where ID = " & me.ID
docmd.runsql "delete from TABLE2 where ID = " & me.ID2
Only now it deletes ALL my records, not just the one currently displayed
my form. So I'm really confused. If I don't change it the delete buttonrelationships
will cause me to have fragmented data, and I'm pretty sure my
and integrity are all set. Please Help! Thanks.
- Follow-Ups:
- Re: What does this mean?
- From: tina
- Re: What does this mean?
- References:
- Re: What does this mean?
- From: tina
- Re: What does this mean?
- Prev by Date: Re: consultant
- Next by Date: RE: jpgs not showing on forms
- Previous by thread: Re: What does this mean?
- Next by thread: Re: What does this mean?
- Index(es):