Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old May 30th, 2007, 07:16 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access 2003 VBA PG 55-56

Creating the TestIfStatement shows an error

Compile error:
Sub or Function not defined"

I'm not sure why this is happening. I checked the code and all looked right? If anyone can help that would be great. I'm just learning VBA.

Below is what I copied out of the vba editor;

Sub TestIfStatement()

    'declare variable to store sales tax value
        Dim curSalesTax As Currency

    'call function to calculate sales tax
        curSalesTax = CalculateSalesTax(500, 0.05)

    'evaluate sales tax and write proper message
    'to debug window
        If curSalesTax <= 10 Then
            Debug.Print "You are Lucky - the amount of tax is nominal."
        ElseIf curSalesTax > 10 And curSalesTax <= 50 Then
            Debug.Print "The amount of sales tax could have bought you a nice meal."
        Else
            Debug.Print "You bought a really nice item for that tax amount."
    End If

End Sub
__________________________________________________ ________________

Thanks!

  #2 (permalink)  
Old May 31st, 2007, 09:21 AM
Friend of Wrox
 
Join Date: May 2006
Location: Jonesboro, AR, USA.
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try sticking Public in front of Sub.

-Dave

  #3 (permalink)  
Old June 7th, 2007, 09:04 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I'm sorry I didn't get back to you earlier on this, but I thank you for the help.

I had put Public in front of Sub and I still couldn't get it to work. I've been so busy lately that I haven't had another chance to try.

Will let you know what I find out after I backtrack to find what I've maybe missed.

Thank You,



  #4 (permalink)  
Old June 9th, 2007, 08:32 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Just like I was thinking...
While skimming through the beginning of chapter 2 I missed one of the functions.

Function CalculateSalesTax(curPrice As Currency, intTaxRate As Double) As Currency

I guess I need to slow down and make sure I get it all.

Thanks!



Similar Threads
Thread Thread Starter Forum Replies Last Post
beg access 2003 vba Michele_Haywood BOOK: Beginning Access VBA 0 November 9th, 2006 09:03 PM
beg access vba 2003 Michele_Haywood Access VBA 0 November 8th, 2006 10:15 PM
Question on Access 2003 VBA Chapter 5 AlexJChang BOOK: Beginning Access 2003 VBA 1 June 7th, 2005 02:04 PM
Beg Access 2000 VBA - Ch 5 - pg 136 - Library? dmrey73 Access VBA 1 January 18th, 2005 05:36 PM
Access 2003 VBA Phone Dialer yandiel Access VBA 0 October 19th, 2004 07:21 PM





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