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!

I want to delete a form in VBA code 1

Status
Not open for further replies.

cc5305

MIS
Oct 4, 2000
70
US
Hi, I want to delete one of the forms by using VB code so the form will be deleted and recreated as the user selects different options in the access database to present different set of data. However, for some reason, very strange too, that I keep getting the message that Access cannot do the deletion at this time and it advises me to stop the code and reset it again to try to delete the form. but the thing is, the form IS deleted by the time the error occur. And sometimes if i just add another form with the same name, it would work just fine... I'm deleting the form by this line:
Docmd.DeleteObject acForm, "form_name"

So now I'm very confused!!!

Can anyone share any ideas? Thanks in Advance.
 
Where is the code for deleting the form. It sounds like it is on the form that is being deleted. Access usually doens't like you doing things like that. -Dustin
Rom 8:28
 
No, I made sure that the code is being called from another Form. Actually, I moved the code from one form to another. And I get the same results for both times.
 
Have you tried deleting the form with a macro instead? I don't know if that will change anything but you never know.

If you are just looking for a quick get around, I think you can just turn your errors off either by using the onError method or by "DoCmd.SetWarnings False" I wouln't suggest doing that all the time, but hey.. if it works it works :). -Dustin
Rom 8:28
 
I'm just curious.. which one worked? Did you turn the warnings off or did you use a macro? -Dustin
Rom 8:28
 
well, I thought the macro worked, which it did a few times. But the same error came back up and not let me delete the form. I don't know why, can't figure out. But I did find a run around solution to what I wanted to do. Thanks.
 
Did you try to Close the current form in code line before deleting.
It seems like a link in between both form's.

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top