Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 31st, 2003, 02:55 PM
Authorized User
 
Join Date: Dec 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access can't find the form error

I am using a list box to select the record to display when opening another form in Access 2002(XP). When I run this code from a command button, I get an error message that says:

Run-time error '2450':
Microsoft Access can't find the form 'frmTest' referred to in a macro expression or Visual Basic code.

The form that won't open is in the same database and can be opened by this code:

DoCmd.OpenForm "frmTest"

Here is my code:

Dim rst As Recordset
Set rst = Forms!frmTest.RecordsetClone 'here is where the code stops
rst.Find "CustomerNumber = " & List0
Forms!frmTest.Bookmark = rst.Bookmark
DoCmd.Close acForm, "frmGoToRecordDialog"

Thanks for your help,

Bill Murrin
Nashville, TN

Nashville_Bill
__________________
Nashville_Bill
 
Old January 1st, 2004, 12:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure if this will fix yr problem or not - but try getting rid of the bang (!), as it's really just a remnant of the past - try using either
Forms.frmTest
or
Form_frmTest
HTH
Steven

I am a loud man with a very large hat. This means I am in charge
 
Old January 1st, 2004, 04:31 PM
Authorized User
 
Join Date: Dec 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply Steven. I tried you suggestion, but I am still having problems and think maybe I should just make it a VB application. It will be a lot more work, but VB seems to be more stable for me.

Nashville_Bill
 
Old January 1st, 2004, 10:35 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

It looks like that form must first be open, then run your code.

 
Old January 2nd, 2004, 10:12 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Once the form is opened, you can set the recordsource as follows:

Set rst = Me.RecordsetClone

But to open a form with a recordset based on the criteria selected in a list box or text box, your code would look something like the following:

Dim strCriteria as string

strCriteria = "[CustomerNumber]=" & Me![List0]
DoCmd.OpenForm "frmTest", , , strCriteria

HTH,

Beth Moffitt
 
Old January 3rd, 2004, 02:27 PM
Authorized User
 
Join Date: Dec 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Beth,

Thanks a lot for the help. I followed an example in a VB6 manual and it wouldn't work. I guess it shouldn't have worked. It seems really simple when you get the code right, huh?

Bill Murrin

Nashville_Bill





Similar Threads
Thread Thread Starter Forum Replies Last Post
error when trying to submit form to access gillrajb Infopath 0 June 8th, 2007 02:06 PM
find textbox in window form vipinpaliwal1980 VB.NET 2002/2003 Basics 1 April 28th, 2006 08:22 AM
Document.form can't find Label bekim Javascript How-To 1 February 13th, 2006 07:39 PM
Open Word Doc from Access - find, find next save donaldmaloney Access VBA 1 May 25th, 2005 11:09 AM
Can't find form mschenk Access 4 December 2nd, 2003 01:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.