DoCmd.OpenForm command is not working as should.

A

Ayo

I have this form with about 4 comand buttons on it but 1 of them is not
working the way it should.

Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Selection Vendor and Reviewer", acNormal
End Sub

Private Sub cmdMainMenu_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Invoice Database Launch", acNormal
End Sub

cmdMainMenu_Click works fine but cmdChangeVendor_Click doesn't work.
"Selection Vendor and Reviewer" doesn't open, nothing open. but when I run it
using the Toggle Breakpoint everything works the way it should. The other
thing is when I try to use this variation:
Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm Forms![Selection Vendor and Reviewer], acNormal
End Sub
I get an error saying that "Selection Vendor and Reviewer" doesn't exist
when I know damn sure it does.
Can any one tell me what is going on here?
Thanks
 
J

John W. Vinson

Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm Forms![Selection Vendor and Reviewer], acNormal
End Sub
I get an error saying that "Selection Vendor and Reviewer" doesn't exist
when I know damn sure it does.

From the Help:

FormName Required Variant. A string expression that's the valid name of a
form in the current database. If you execute Visual Basic code containing the
OpenForm method in a library database, Microsoft Access looks for the form
with this name first in the library database, then in the current database.

You're not passing the form name as a text string. You're passing a Form
object.

Try

DoCmd.OpenForm "Selection Vendor and Reviewer", acNormal


John W. Vinson [MVP]
 
A

Ayo

I don't know if you saw the whole thing I wrote this were my original codes:
Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Selection Vendor and Reviewer", acNormal
End Sub

Private Sub cmdMainMenu_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Invoice Database Launch", acNormal
End Sub

The first one doesn't work but the second works fine. Thats what I am trying
to figure out.

John W. Vinson said:
Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm Forms![Selection Vendor and Reviewer], acNormal
End Sub
I get an error saying that "Selection Vendor and Reviewer" doesn't exist
when I know damn sure it does.

From the Help:

FormName Required Variant. A string expression that's the valid name of a
form in the current database. If you execute Visual Basic code containing the
OpenForm method in a library database, Microsoft Access looks for the form
with this name first in the library database, then in the current database.

You're not passing the form name as a text string. You're passing a Form
object.

Try

DoCmd.OpenForm "Selection Vendor and Reviewer", acNormal


John W. Vinson [MVP]
 
B

boblarson

Double check to make sure that the form name is exactly the same (that there
are not any extra spaces, etc.) by right-clicking on the form and selecting
RENAME and then copy the name and then paste it into your code.

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 
A

Ayo

I did that already. But I will try it again.

boblarson said:
Double check to make sure that the form name is exactly the same (that there
are not any extra spaces, etc.) by right-clicking on the form and selecting
RENAME and then copy the name and then paste it into your code.

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


Ayo said:
I have this form with about 4 comand buttons on it but 1 of them is not
working the way it should.

Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Selection Vendor and Reviewer", acNormal
End Sub

Private Sub cmdMainMenu_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Invoice Database Launch", acNormal
End Sub

cmdMainMenu_Click works fine but cmdChangeVendor_Click doesn't work.
"Selection Vendor and Reviewer" doesn't open, nothing open. but when I run it
using the Toggle Breakpoint everything works the way it should. The other
thing is when I try to use this variation:
Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm Forms![Selection Vendor and Reviewer], acNormal
End Sub
I get an error saying that "Selection Vendor and Reviewer" doesn't exist
when I know damn sure it does.
Can any one tell me what is going on here?
Thanks
 
A

Ayo

I just tried it again. It worked one time only, and after that it stop
working again.

boblarson said:
Double check to make sure that the form name is exactly the same (that there
are not any extra spaces, etc.) by right-clicking on the form and selecting
RENAME and then copy the name and then paste it into your code.

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


Ayo said:
I have this form with about 4 comand buttons on it but 1 of them is not
working the way it should.

Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Selection Vendor and Reviewer", acNormal
End Sub

Private Sub cmdMainMenu_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Invoice Database Launch", acNormal
End Sub

cmdMainMenu_Click works fine but cmdChangeVendor_Click doesn't work.
"Selection Vendor and Reviewer" doesn't open, nothing open. but when I run it
using the Toggle Breakpoint everything works the way it should. The other
thing is when I try to use this variation:
Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm Forms![Selection Vendor and Reviewer], acNormal
End Sub
I get an error saying that "Selection Vendor and Reviewer" doesn't exist
when I know damn sure it does.
Can any one tell me what is going on here?
Thanks
 
B

boblarson

Maybe you should just change the name of the form to something shorter and
without spaces:
Like frmSelVendorAndReviewer
and then open using that.

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


Ayo said:
I just tried it again. It worked one time only, and after that it stop
working again.

boblarson said:
Double check to make sure that the form name is exactly the same (that there
are not any extra spaces, etc.) by right-clicking on the form and selecting
RENAME and then copy the name and then paste it into your code.

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


Ayo said:
I have this form with about 4 comand buttons on it but 1 of them is not
working the way it should.

Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Selection Vendor and Reviewer", acNormal
End Sub

Private Sub cmdMainMenu_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Invoice Database Launch", acNormal
End Sub

cmdMainMenu_Click works fine but cmdChangeVendor_Click doesn't work.
"Selection Vendor and Reviewer" doesn't open, nothing open. but when I run it
using the Toggle Breakpoint everything works the way it should. The other
thing is when I try to use this variation:
Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm Forms![Selection Vendor and Reviewer], acNormal
End Sub
I get an error saying that "Selection Vendor and Reviewer" doesn't exist
when I know damn sure it does.
Can any one tell me what is going on here?
Thanks
 
A

Ayo

That didn't work. I found out that when I open the form by itself from the
database window, without opening use the other form, the button works fine.
It just don't work when I try to when I try to work things the way it was
design to.

boblarson said:
Maybe you should just change the name of the form to something shorter and
without spaces:
Like frmSelVendorAndReviewer
and then open using that.

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


Ayo said:
I just tried it again. It worked one time only, and after that it stop
working again.

boblarson said:
Double check to make sure that the form name is exactly the same (that there
are not any extra spaces, etc.) by right-clicking on the form and selecting
RENAME and then copy the name and then paste it into your code.

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


:

I have this form with about 4 comand buttons on it but 1 of them is not
working the way it should.

Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Selection Vendor and Reviewer", acNormal
End Sub

Private Sub cmdMainMenu_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Invoice Database Launch", acNormal
End Sub

cmdMainMenu_Click works fine but cmdChangeVendor_Click doesn't work.
"Selection Vendor and Reviewer" doesn't open, nothing open. but when I run it
using the Toggle Breakpoint everything works the way it should. The other
thing is when I try to use this variation:
Private Sub cmdChangeVendor_Click()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm Forms![Selection Vendor and Reviewer], acNormal
End Sub
I get an error saying that "Selection Vendor and Reviewer" doesn't exist
when I know damn sure it does.
Can any one tell me what is going on here?
Thanks
 
B

boblarson

You don't, by chance, have this form already opened as a subform in another
form do you?
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 

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