Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 July 10th, 2004, 12:01 PM
Authorized User
 
Join Date: Jul 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sub or Function Not Defined

Hi All,
Thanks for your gracious welcome, Bob. I'm doing an exercise in which the authors told me to create a new subroutine called FormFonts, like so:

Sub FormFonts(strFont As String)

  Dim frmCurrent As Form
  Dim ctlControl As Control

  For Each frmCurrent In Forms
    For Each ctlControl In frmCurrent.Controls
      ctlControl.FontName = strFont
    Next
  Next
End Sub

Next, we are told to use the immediate window to run this code. The authors indicate that running the code should generate the following error message: "Run-time error '436' Object doesn't support this property or method" and then explain why this is so. Despite the error, however, text of the form's text boxes and labels should reflect change up to the control that is suppose to cause the error to occur.

When I ran this code, I received a compile error, "Sub or Function not defined." Can someone tell me what the problem may be?

Thanks much.


 
Old July 10th, 2004, 12:26 PM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Olivia,

I think that you must put a breakpoint in your code and start your form and then you can call the sub in the immediate window.

Excuse my english i leave in Belgium and spoke french.

Hello2lu
 
Old July 10th, 2004, 12:36 PM
Authorized User
 
Join Date: Jul 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response, Hello2lu.

Unfortunately, adding the break point didn't resolve the problem.

But, again, thanks for your response. Also, you can communicate in at least two languages, I can only communicate in English. In my humble opinion, no apologies for your English are necessary.:)

 
Old July 10th, 2004, 12:48 PM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Olivia,

when you call your sub in the immediate window, is your form in 'create mode' or 'form mode' ?

I try your exercise and when i call the sub in 'creation mode' i receive the same message (procedure or sub not defined) and when i start in 'form mode' and reach the breakpoint (placed in form_load), if i call the sub, i receive the message that your expect (Object doesn't support this property or method).

Hello2lu

 
Old July 10th, 2004, 01:56 PM
Authorized User
 
Join Date: Jul 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, again Hello2lu!

While problem solving (after I had posted my question), I recreated the routine and inadvertently made it private. Thus, your tip about form vs design view initially didn't work.

After realizing what I had done and correcting the problem, your form vs design view tip has resolved my problem.

Have a great day!:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
User Defined function in XSL1.0 elayaraja.s XML 1 July 22nd, 2008 03:24 AM
Go for View or User Defined function vinod_yadav1919 SQL Server 2000 1 December 12th, 2007 05:18 AM
Help : compile error : sub or function not defined Specialist VB How-To 2 June 20th, 2007 04:34 AM
error function not defined Dj Kat Ajax 6 March 6th, 2006 12:02 PM
User Defined Function niravp SQL Server 2000 7 November 29th, 2004 02:18 PM





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