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

July 10th, 2004, 12:01 PM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

July 10th, 2004, 12:26 PM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 10th, 2004, 12:36 PM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.:)
|

July 10th, 2004, 12:48 PM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 10th, 2004, 01:56 PM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!:)
|
|
 |