DoCmd.OpenForm command is not working as should.

  • Follow


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
0
Reply Utf 2/2/2008 3:16:01 AM

On Fri, 1 Feb 2008 19:16:01 -0800, Ayo <Ayo@discussions.microsoft.com> wrote:

>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]
0
Reply John 2/2/2008 3:28:10 AM

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" wrote:

> On Fri, 1 Feb 2008 19:16:01 -0800, Ayo <Ayo@discussions.microsoft.com> wrote:
> 
> >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]
> 
0
Reply Utf 2/2/2008 3:52:00 AM

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" wrote:

> 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
0
Reply Utf 2/2/2008 3:58:01 AM

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

"boblarson" wrote:

> 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" wrote:
> 
> > 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
0
Reply Utf 2/2/2008 4:00:00 AM

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

"boblarson" wrote:

> 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" wrote:
> 
> > 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
0
Reply Utf 2/2/2008 4:03:01 AM

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" wrote:

> I just tried it again. It worked one time only, and after that it stop 
> working again.
> 
> "boblarson" wrote:
> 
> > 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" wrote:
> > 
> > > 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
0
Reply Utf 2/2/2008 4:10:00 AM

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" wrote:

> 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" wrote:
> 
> > I just tried it again. It worked one time only, and after that it stop 
> > working again.
> > 
> > "boblarson" wrote:
> > 
> > > 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" wrote:
> > > 
> > > > 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
0
Reply Utf 2/2/2008 5:37:01 AM

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.
__________________________________


0
Reply Utf 2/3/2008 8:38:05 PM

8 Replies
1060 Views

(page loaded in 0.344 seconds)


Reply: