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