Wrox Programmer Forums
BOOK: Beginning Access VBA
This is the forum to discuss the Wrox book Beginning Access 2002 VBA by Robert Smith, Dave Sussman, Ian Blackburn, John Colby, Mark Horner, Martin Reid, Paul Turley, Helmut Watson; ISBN: 9780764544026
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning 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 26th, 2003, 07:00 PM
Registered User
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beg Access 2002 VBA chap 6 Capitilzation

Capitalize Procedure exercise

I keep getting a
Run-time error '94': Invalid use of Null
when I run this exercise.

Debug goes to this line: rec(strFld) = UCase$(rec(strFld))

My code is below.

Function Capitalize(strTable As String, strFld As String)

Dim db As Database
Dim rec As Recordset

Set db = CurrentDb()
Set rec = db.OpenRecordset(strTable)

Do While Not rec.EOF
    rec(strFld) = UCase$(rec(strFld))

Capitalize = True

End Function

I call the procedure with
? capitalize ("tblCompany", "Country")

When I step through it the locals window shows

Expression: Capitalize
Value: empty
Type: variable

Thanks for any help

Old December 26th, 2003, 11:57 PM
Registered User
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

I copied your code verbatim, executing it against the database off the Access 2002 VBA cd, and it executed fine.

I did also however go into the table tblCompany and cleared out the country name in a couple of records. When I ran the code again, I do get the error.

My assumption is that this is either a normal error returned by the UCase function if the field it encounters is null, or, that there is a level of error checking being performed, which will return errors in this type of situation (my thought being the level could be changed to not return errors when a null field is encountered).

I'd double-check the records in tblCompany. You could also type a Debug command in the immediate window to determine on what record the error is occurring. For example

debug.Print rec("CompanyID").

I hope this helps.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Beg Access 2K chap 8 ManFriday Access VBA 7 July 25th, 2007 05:18 AM
Beg Access VBA 2000 - icre cream database Michele_Haywood Access VBA 1 December 6th, 2006 08:38 AM
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
Missing file from Beg Access 2002 VBA CD mgheinlein Wrox Book Feedback 0 July 26th, 2003 12:33 AM

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