Help with "Form DoCmd.Open and DoCmd.Close

A

Ayo

The following two lines of code is not operating correctly.

Private Sub cmdChangeVendor1_Click()
DoCmd.Close acForm, "Invoice by Market Reviewer"
DoCmd.OpenForm "Selections Vendor and Reviewer", acNormal
End Sub

When I click on the cmdChangeVendor1 button, I expect the form "Invoice by
Market Reviewer" to close and the form "Selections Vendor and Reviewer" to
open. But that is not the result I get. The form "Invoice by Market Reviewer"
closes but that is about it. Nothing else opens. I have two forms that
behaves this way. I have checked and re-check the code many times to make
sure for spelling and syntax. Everything, as far as I can see, is correct.
Any help will be greatly appreciated. Thanks.
Ayo
 
B

BruceM

If you comment out (place an apostrophe in front of) the DoCmd.Close line,
does the Selections Vendor and Reviewer form open as it should?
 
D

Dale Fye

Are you certain that you have the spelling of the form name exactly correct
(I cannot count the number of times that I have made that mistake). Check
that you don't have two spaces right next to one another either in the form
name or in the OpenForm statement. This is one of the reasons I never
include spaces in my object names.
 
A

Ayo

The same thing happened. It just closed everything and nothing opened. This
is very strange.
 
A

Ayo

That is not the issue. That was my first reaction. But I have gone through
it, checked and re-checked and I keep getting the same result.
 
R

Ron2006

What is the name of the form you are sitting in when you press the
button.?

If it is "Invoice by Market Reviewer" then the second command is NOT
executed because the form has closed.

reverse the order..


Ron
 
B

Bob Quintal

:
What is the name of the form you are sitting in when you press the
button.?

If it is "Invoice by Market Reviewer" then the second command is
NOT executed because the form has closed.

reverse the order..


Ron

Not true. The code will continue, at least in Access <= 2003.
 
B

BruceM

Can you open Selections Vendor and Reviewer from the database window (that
is, by double-clicking the form's icon)?
 
R

Ron2006

Can you open Selections Vendor and Reviewer from the database window (that
is, by double-clicking the form's icon)?







- Show quoted text -

I humbly withdraw my comment. Bob is correct.

If you simply open the other form with the button does it work?
The prior form does NOT have to be closed to open another form.

Ron
 
B

BruceM

So did you solve this or not? I can't tell.

Ron2006 said:
I humbly withdraw my comment. Bob is correct.

If you simply open the other form with the button does it work?
The prior form does NOT have to be closed to open another form.

Ron
 

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