Wrox Programmer Forums
|
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 November 29th, 2003, 10:42 PM
Registered User
 
Join Date: Nov 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't find form

I am using Access 2000. To open a form, I use the following code:

dim strName as String

strName = "frm No Price"
docmd.OpenForm strName,,,,,acDialog

This works fine. But I get a "Run-time error '2450'. Microsoft Access can't find the form 'frm No Price' referred to in a macro expression or Visual Basic code." when I try this:

dim frmName as Form

Set frmName = Forms("frm No Price")

Why can't it find the form in the second instance when it has no trouble finding the form in the first instance?

- Mark
 
Old December 1st, 2003, 10:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Hmmmm... Mark, my first suggestion is to get rid of the spaces in the form name and try again. As a rule, you should never use spaces in names for forms, reports, tables, queries, etc. Use a combination of upper and lower case and underscores ( _ ) to make your names easier to understand; but don't use spaces.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old December 1st, 2003, 08:04 PM
Registered User
 
Join Date: Nov 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply, Greg. I discovered that the DAO library was not loaded, and that caused the problem. After going to Tools | References and loading all the DAO libraries, it worked as it should.

Two related questions: although the code worked even with spaces in the form and report names, there must be times when spaces cause problems. What sort of problems do they cause?

Secondly, do I need to load all the DAO libraries or just the latest one (I think it is version 3.6)?

- Mark
 
Old December 2nd, 2003, 09:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by mschenk
although the code worked even with spaces in the form and report names, there must be times when spaces cause problems. What sort of problems do they cause?
Well, not so much problems as inconveniences.

Over the years, Microsoft has tried to make its software "idiot proof" by providing automatic responses to typewritten text. Sometimes it works, and other times not. For example, you're in Word and that annoying paper clip appears when it thinks it's trying to be helpful and usually it's not. One good thing Access does is that when you type VBA code, properties and collections of control objects autofinish when you type.

So if you're coding something for a textbox, for example, if your textbox is named "My Text Box" then you'll always have to type Me.[My Text Box].This or Me.[My Text Box].That; however, not so if you name it something like "txtMyTextBox". In this instance, as soon as you type "Me.txt", Access will list out all of your control objects. Continue typing "Me.txtMy" and sure enough "Me.txtMyTextBox" will appear and you just press space and keep going. This is very handy and speeds you up a great deal.

Naming conventions for objects are "txtMyTextBox", "cboMyComboBox", "cmdMyCommandButton", "grpMyOptionGroup", etc. In that way, when the autofill kicks in, like objects are alphabetized and grouped together for easy retrieval.

Note: the bang (!) doesn't invoke this autofill and so the period is used all the time now. The bang is becoming obsolete.

Quote:
quote:Secondly, do I need to load all the DAO libraries or just the latest one (I think it is version 3.6)?
I only load the latest one.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old December 2nd, 2003, 01:31 PM
Registered User
 
Join Date: Nov 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the advice, Greg. Fortunately I am early enough in my project that changing table names, form names, etc. won't be impractical.
I'm glad the bang is obsolete. I could never remember when to use the period and when to use the bang.
- Mark





Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms Collection can't find form Loralee Access 3 December 28th, 2006 12:17 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
Associate "Find" command on form grahampinkney Access 3 August 23rd, 2004 05:51 AM
Access can't find the form error bmurrin Access 5 January 3rd, 2004 02:27 PM





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