Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > BOOK: Beginning Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 26th, 2003, 07:00 PM
Registered User
 
Join Date: Dec 2003
Location: Reno, NV, USA.
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.Edit
    rec(strFld) = UCase$(rec(strFld))
    rec.Update
    rec.MoveNext
Loop

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


Reply With Quote
  #2 (permalink)  
Old December 26th, 2003, 11:57 PM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Beg Access 2K chap 8 ManFriday Access VBA 7 July 25th, 2007 06: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 01:33 AM



All times are GMT -4. The time now is 10:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.