Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform Deletetion

Status
Not open for further replies.

wreded

Technical User
Dec 18, 2001
119
US
Have a form with tabs tying several tables together. On the tabs are subforms. i'm having trouble with 2 that are continuous subforms. These subforms list different training data and have a "Delete" button next to each item. The "Delete" buttons work as advertised when designing the form or running the form stand-alone. When called from within the main form a message box pops up saying "The command or action 'DeleteRecord' isn't available now.". It's the standard Access delete button and code. i can't understand why it'll work as stand-alone but not as a subform.
Thanks,
Dave
 
It should work so long as the button is in the detail section with the record on the sub form. Is that the issue?
 
Yep, it's in the detail section along with the data. That's what's so puzzling to me.
 
The two subforms are not using the same "Training data" recordsource, are they?

What is the code it is trying to run. Does it work if you manually delete the record in the subform with the delete button and the record selector selected?
 
On Your recommendation i tried removing one of the subforms and rerunning the form. No dice, still the same error.
Good idea though.
Dave
 
What about manually deleting a record without the button?
 
i didn't build that into the form. Looks like i gotta do it over and pay closer attention while doing so ::).
Thanks,
Dave
 
Just design it and turn on record selectors.

Put it it form view, select a record selector and hit delete. It will either work or not. The error message may indicate why.
 
How are ya wreded . . .

The problem is you've moved focus to the mainform away from the subform. The record in the subform you want to delete [purple]has to have the focus[/purple] before a deletion command can be executed. So what you need to do in the code in your mainform is set focus back to the subform 1st, before you execute the commands for deletion.

Special Note ... in your post origination you quote a problem with the buttons in the detail area, yet you want to solve a problem with code running in the mainform!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
TheAceMan1, how's it goin?
The subform has the focus, the delete button is on the subform.
It looks kinda like this...
Code:
MainForm
Data      Data

Subform
DataDataData   Date     Data   Button
DataDataData   Date     Data   Button
DataDataData   Date     Data   Button
DataDataData   Date     Data   Button

There are other buttons on the MainForm, but the subform "Delete" button only works on the subform. i tried setting focus to a label on the subform and got the same results ("The command or action 'DeleteRecord' isn't available now.").

i guess i should restate that when the subform is called or displayed by the main form the delete button doesn't work in the subform.
 
What is the code it is trying to run. Does it work if you manually delete the record in the subform with the delete (key) button and the record selector selected?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top