Solved

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

Posted on 2000-04-11
19
708 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
  • 2
  • +3
19 Comments
 
LVL 7

Expert Comment

by:Believer
ID: 2706219
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
ID: 2706263
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
ID: 2706353
... 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 14

Expert Comment

by:mgrattan
ID: 2706377
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
ID: 2706402
... 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
ID: 2706516
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
ID: 2706897
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
ID: 2707176
how about


  UCase(cStr(chr$(___)))

0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2708271
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
 
LVL 9

Expert Comment

by:BrianWren
ID: 2708284
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
ID: 2708611
Brian: Neato!  How'd you get those bullets? <grin>  Seriously!
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2708898
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
ID: 2709333
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
ID: 2720221
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
ID: 2722240
?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
ID: 2723780
Great!  I was wondering about the outcome and solutions on this one...

Brian
0
 

Author Comment

by:pbetts
ID: 2746966
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
ID: 2747992
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
ID: 2754168
Thanks Brian, I suppose this was in the FAQ somewhere..... but hey.... who gets the time :)

Peter Betts
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

632 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