Can't load or unload this object

S

Stuart Grant

I have a small form Exchange Rates on which I enter the current exchange
rates for two or more currencies.

It has two buttons Next and Finish

When I click Next it moves to the next record but when I click Finish I get
the error message "Can't load or unload this object". The code for the On
Click Event is
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Unload Form(Exchange Rates)

Why?

Stuart
 
B

Brendan Reynolds

Is that your actual code? The reason I ask is that I can not see any way in
which that code would compile, let alone run, in VBA code behind an Access
form.

There's no function named 'Form' in Access or VBA, and to pass the name of a
form or other object to a function it would need to be enclosed in quotes.

To close an Access form, use the DoCmd.Close method. I suspect your code may
be adapted from an example intended for other VBA-enabled applications such
as Word or Excel. Access forms are very different from the UserForms used by
those applications.
 
S

Stuart Grant

Brendan: Thanks for your help

I don't know where the code came from. It didn't make sense to me. It must
have come from the Button Wizard which I used to create the button since it
has all the trade mark boiler-plate On Error and Exit code.

Anyway I replaced it with DoCmd.Close and it works fine. Thanks again.

Stuart
 

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