Delete record failing?

agehoops

Registered User.
Local time
Today, 18:41
Joined
Feb 11, 2006
Messages
351
The command button I have for deleting a record is not working. It runs a few queries to move data to another table, delete the data from the linked tables, and then runs the code to delete that record, however that bit isn't running.

When i use the following code it simply does nothing
Code:
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

But when i use the following code, it gives me an error saying "The delete record command is not available"

Code:
DoCmd.RunCommand acCmdDeleteRecord

thanks for help in advanced :)
 
Maybe your form has AllowDeletions set to NO.

Or you are trying to delete a record that has related records (although you'd get a meesage to this effect if you tried to delete).

Chris
 
Nope, allow deletions is set to yes. I am deleting a related item but what it's doing is deleting the data from the linked tables first, and then being told to delete the main record, so there then isn't anything linked to it. It is working on another form I think in different tables just not this one now.
 
Are you able to delete the record in the forms datasource ? i.e. in the underlying query or table?

Is the datasource an aggregate query?
 
Last edited:
I can delete the data straight from the table, and the queries that are running are deleting the data no problems. Just this is failing.

The form is based on the table itself not a query
 
Do you have two forms open?

Is your form bound (I'm clutching at straws here)?
 
Last edited:
Just one form open but it contains a subform?
When you say bound what do you mean exactly? It is based on one table (except for subform making it 2) and all of the fields are bound bar 3 (and command buttons) however I have another form that is doing the same thing which works perfectly?
 
Bound means the data is directly linked to a datasource as opposed to unbound where you might synchonise with the datasource using VBA code.

Is there any code behind your form? While in your form hit Ctrl-G to see all the code within that form.

After that, wait for someone else to help, post your d/b, or create the form from scratch and see what happens.
 
Then yea it's bound. The data isn't be altered by VB at all. There is quite a bit of code in the form but nothing complex that should be stopping a record being deleted.
 
Ok really confused now. It just started working :S God knows why but it worked. :) Thanks for the help anyway :)
 

Users who are viewing this thread

Back
Top Bottom