Solved

Compile Error..... Ucase(chr$......

Posted on 2000-04-11
19
692 Views
Last Modified: 2012-05-04
I wrote a database and gave a copy to a friend. He keeps getting Compile Error and VB goes to code and highlights a Ucase(Chr$... statement. Obviously the relevent addin/module whatever for the Ucase function is not included in his Tools->References ..... can someone please tell me which one is needed for this function? I cant tell from my setup
Running Access 2000...
0
Comment
Question by:pbetts
  • 7
  • 7
  • 2
  • +3
19 Comments
 
LVL 7

Expert Comment

by:Believer
Comment Utility
I think a reference in general is missing, not just the UCase-specific one.  Walk your friend thru getting to a code module, then check the references.  You'll probably find that one's missing and hopefully it's just a matter of telling it where the file is.  
0
 
LVL 9

Accepted Solution

by:
BrianWren earned 200 total points
Comment Utility
UCase() and Chr() are in:

     Visual Basic For Applications

file

     C:\PROGRAM FILES\COMMON FILES\MICROSOFT SHARED\VBA\VBA332.DLL

have your friend open a module design window, and from the menu select "Tools | References..." and make sure that "Visual Basic For Applications" is present and checked.  If not, scroll dow to find it.  If it is there but unchecked, chek the box beside it.  

If it is not there, click the Browse button, and search for the file.

Brian




0
 

Author Comment

by:pbetts
Comment Utility
... I did that, he says VB for Applications is checked
{
Peter
yes i do have Visual basics for applications, its the first one and it is marked in the little box.
Do you think I might not have saved our alterations saturday nite?
}

.... i got him to rem out the line and it worked ok then, now its back !!! If rem-ming the line worked then it still leaves the problem. Im no expert, I just added a heap of libraries to mine until it worked..... I wld like to know what I am doing this time :)


0
 
LVL 14

Expert Comment

by:mgrattan
Comment Utility
While you're in the Tools|References box make sure none of the checked references has MISSING: in its description.  If it does, then uncheck the reference, close the window, then go back into Tools|References and re-select the reference if it is needed.

0
 

Author Comment

by:pbetts
Comment Utility
... I did that, he says VB for Applications is checked
{
Peter
yes i do have Visual basics for applications, its the first one and it is marked in the little box.
Do you think I might not have saved our alterations saturday nite?
}

.... i got him to rem out the line and it worked ok then, now its back !!! If rem-ming the line worked then it still leaves the problem. Im no expert, I just added a heap of libraries to mine until it worked..... I wld like to know what I am doing this time :)


0
 
LVL 9

Expert Comment

by:BrianWren
Comment Utility
OK then, I think that there is something else wrong with that line.  Can you post the entire statement?

One thing to try is to start unpacking that statement.  If you have for instance:

     For i = 65 to 70
          Debug.Print UCase(Chr$(i + 2))
     Next i

Then try:

     Dim k as integer
     For i = 65 to 70
          k = i + 2
          Debug.Print UCase(Chr$(k))
     Next i

Then

     Dim k as integer
     Dim s as string
     For i = 65 to 70
          k = i + 2
          s = Chr$(k)
          Debug.Print UCase(s)
     Next i

Etc.

Brian
0
 

Author Comment

by:pbetts
Comment Utility
hmmm.. the statement works fine on my PC here and at home... I have been using the database for nearly 3 years. Its only when i sent it to him that we got the error. I have many instances of Ucase() the same, and all work fine. I'm thinking the error he reported after we remmed the first one was another instance of Ucase... but he isnt online  yet to ask.   I will make sure he has the correct .DLL  for VB /Apps and get back soon.... stay tuned.....
0
 
LVL 3

Expert Comment

by:MikeRenz
Comment Utility
how about


  UCase(cStr(chr$(___)))

0
 
LVL 9

Expert Comment

by:BrianWren
Comment Utility
Sometimes, (the why of which I'm not that clear on...), syntax gets really, really picky.

For instance, let's say you had:

   Var$ = (UCase(Chr$(KeyAscii)))

Sometimes, (I'm not sure when), this won't work, but

   Var$ = UCase(Chr$(KeyAscii))

will.  Or

   Var$ = UCase$(Chr$(KeyAscii))

Surrounding a statement with parens would seem to mean nothing, since in algebra it does mean nothing, (  A = 1 + 2  is the same as  A = (1 + 2), dor instance).  But in VBA, surrounding a statement with parens indicates implicit typing.  For instance, if you had the function:

Function ABC(i as integer) As string
End Function

And you had also

    Dim t as Double
       .
       .
       .
     str = ABC(t)

you would get a type mismatch, but

    str = ABC((t))

will work, because the extra parens implicitly type 't' as an integer.

Plus, The prototype of Ucase() in the object browser is:

    Function UCase(String)

but the prototype of UCase$() is

    Function UCase$(String As String) As String

With the '$' all of the variables are explicitly strings.  

Who knows?  Might make the difference...

What does the db do if you open this module for design on the machine it's not working on, and click the 'Compile' button on the toolbar?

Brian
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 9

Expert Comment

by:BrianWren
Comment Utility
BTW:

 •   Have you tried making a backup copy, then repairing the one that doesn't work?

 •   Have you tried creating a new DB and importing all of the objects of the failing DB into the new one to see if the new one has the same problem?
0
 
LVL 7

Expert Comment

by:Believer
Comment Utility
Brian: Neato!  How'd you get those bullets? <grin>  Seriously!
0
 
LVL 9

Expert Comment

by:BrianWren
Comment Utility
I didn't get them from Smith and Wesson!  (What idiots...)

Hold down the alt key, type, in order, 0 1 4 9, then let the alt key up.  I used spc Alt+0149 spc spc spc.

alt +

0187    »        0215    ×
0162    ¢        0247    ÷
0148    ”        0147    “
0189    ½        0190    ¾
0188    ¼        0186    º

and so on.  If you open character map, and select one of the bottom half characters, in the status bar, the combination is shown.
0
 
LVL 9

Expert Comment

by:ornicar
Comment Utility
Hi! pbetts,
Did you try 2nd BrianWren's suggestion?
I got the same problem, no way to get rid of it by playing with the librairies. I think the only successful way was creating a new database, check if I can write these statements and if yes, importing all objects from the bad database.
0
 

Author Comment

by:pbetts
Comment Utility
Thanks guys.......
OK..... I had him open a form in design mode, View->code
Debug->Compile and this is what he mailed me :
Peter
***********
 I did what you advised opened up several forms, one at a time, From code window  I selected Debug>compile race.  Screen went to "compile error  can't find project,  high lited   Mid$
clicked & then it went to  references,all top items ticked.

  Then I reinstalled Office  2000.

Started the program  however same thing happened.  went to Micobasics  and highlited Ucase.
*************
He swears VB for Apps is checked ( 1st itme in references)..... cld he have an older version of VBA332.DLL ???
Mine is dated 17/11/96 ( which seems kinda old???? ) Version 3.0.7019

I will recreate the database via new one and import all the objects and send it to him. I could step him through it I suppose, but it took an hour to get him to check the references :(



0
 

Author Comment

by:pbetts
Comment Utility
?What Library - simple question hahaha
The original question was answered by Brian. so he gets the nod.
As for the continuing problem, thanks to all. Thanks ornicar for suggesting I tried brians 2nd suggestion. I "recreated" the database, recompiled it and sent it on using WINRAR.sfx ( rather than Winzip, dunno why). Lo and Behold!!! It worked. I guess we still dont know exactly WHY it worked, but then if we did there'd be no fun anymore would there !
Peter Betts.... today a happy little camper :)
0
 
LVL 9

Expert Comment

by:BrianWren
Comment Utility
Great!  I was wondering about the outcome and solutions on this one...

Brian
0
 

Author Comment

by:pbetts
Comment Utility
Brian..... did you get 200 points?????
It shows you only got 20!!!!!!. We all saw it was posted for 200 points, and that is what was taken off my available points. The last time you answered a question for me for 100 you only got 10. Please let me know and I will contact the help people if it is so......

Peter Betts.....



0
 
LVL 9

Expert Comment

by:BrianWren
Comment Utility
Peter,

    Once an answer is accepted, the value of the question goes to 10% of the original.  When it says 20 pts, I can have gotten the results of an original 196 to 204 pts.  (When the 'grade' is 'A', the person who answered gets 4 times that much.  For a 'B', the multiplier is 3, etc.)

    So. I got the points.  Thank you so much for your concern!  (A rare thing these days...)

Brian

0
 

Author Comment

by:pbetts
Comment Utility
Thanks Brian, I suppose this was in the FAQ somewhere..... but hey.... who gets the time :)

Peter Betts
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now