Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 December 30th, 2009, 06:07 PM
Registered User
 
Join Date: Dec 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default access module's are not recognized

I'm having trouble with some of my VBA modules in Access 2003.

This is an example of my VBA code:

Option Compare Database
Public Function IsPast(DateSource) As String
If DateSource <= Now() Then
IsCurrent = "Yes"
Else
IsCurrent = "No"
End If
End Function

This module saved in the same database as a query containing this SQL code:

SELECT SalesTaxTransactions.Date, IsPast([Date]) AS Past
FROM SalesTaxTransactions;

When I try to view this query in datasheet view I get this error message:

Undefined function 'IsPast' in expression.

I would appreciate any input on why I am recieving this error.

Thanks
 
Old January 22nd, 2010, 09:13 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

Hmmm... try fixing your code to see if it wakes it up. Note, since you're working with dates and not times as well, you don't need the Now() function, you just need the Date() function. Also, you didn't pass anything out of the function.

Option Compare Database

Public Function IsPast(DateSource as Date) As String

Dim IsCurrent as String

If DateSource <= Date() Then
IsCurrent = "Yes"
Else
IsCurrent = "No"
End If

IsPast = IsCurrent

End Function
---------------------

Because there is a built-in Access function called Date(), you need to change the name of your field in SalesTaxTransactions from Date to something else, e.g. TransactionDate. If not, it will confuse the computer and cause errors.

SELECT SalesTaxTransactions.TransactionDate, IsPast([TransactionDate]) AS Past
FROM SalesTaxTransactions;
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Forums module's DeletePost function will.wei BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 9th, 2009 10:38 PM
ruby is not recognized.... Crippy RoR Ruby on Rails 1 July 16th, 2008 08:37 AM
Accessing a VBA module's method from VBScript hamffjs Access VBA 3 November 28th, 2006 09:27 AM
not recognized nachtegaal9999 ASP.NET 1.0 and 1.1 Basics 0 April 25th, 2006 02:04 PM
ch15: can't get JSTL to be recognized brownale2k JSP Basics 1 August 8th, 2003 04:32 PM





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