Record not deleted by using form.

G

Guest

When I try to delete a record using a form, I get a pop-up message saying the
action is irreversible. If I choose to go ahead with the deletion, the form
indicates the record is deleted. However, if I then open the table the
record is there and when I go back in the form the record is still there.
What's wrong?

Thank you.

--Lincoln
 
G

Guest

If it's not deleted there must be another related record which doesn't allow
the cascading delete. If possible try with a copy of the db on a local
machine. Create a query with the designated tables and try to delete the
record there by hand. If it is not working you will get an error message
indicating why it will not delete the record.

hth
 
G

Guest

weird, try creating a form with the wizard based on the same recordset you
have now. See if you can delete from that... just for testing purposes
 
G

Guest

Okay. Turns out my form is based on a query as the record source. When I
created a form using the table as my record source I could delete the record.
When I created a form using the same query as my record source deleting
would not delete the record in the table. So is there a way to keep my form
using the query as my record source and still be able to delete the related
record in the table the query is based on?
 
G

Guest

That would be possible but because a query is used the table is probably
related to another table or query. In that case you have to create your own
delete option.

When you add a button on the form you could use something like:

docmd.runsql "DELETE * FROM [tablename] WHERE [id]='" & me.[id] & "'"

note: replace the tablename with the table the record should be deleted
from. Replace the [id] field with the formfield which is actually related in
the query. At the end I placed a couple of quotes and double quotes. When the
[ID] field is a number field the last piece of code looks like this: Where
[id]= " & me.[ID]

hth
 
G

Guest

Thank you very much Maurice.

I ended up changing the record source to the table. Then I unbound those
fields which ended up w/ "#Name?" when I first made the change. Now
everything seems to work fine.

--Lincoln

Maurice said:
That would be possible but because a query is used the table is probably
related to another table or query. In that case you have to create your own
delete option.

When you add a button on the form you could use something like:

docmd.runsql "DELETE * FROM [tablename] WHERE [id]='" & me.[id] & "'"

note: replace the tablename with the table the record should be deleted
from. Replace the [id] field with the formfield which is actually related in
the query. At the end I placed a couple of quotes and double quotes. When the
[ID] field is a number field the last piece of code looks like this: Where
[id]= " & me.[ID]

hth

--
Maurice Ausum


Lincoln said:
Okay. Turns out my form is based on a query as the record source. When I
created a form using the table as my record source I could delete the record.
When I created a form using the same query as my record source deleting
would not delete the record in the table. So is there a way to keep my form
using the query as my record source and still be able to delete the related
record in the table the query is based on?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top