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

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...
pbettsAsked:
Who is Participating?
 
BrianWrenConnect With a Mentor Commented:
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
 
BelieverCommented:
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
 
pbettsAuthor Commented:
... 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mgrattanCommented:
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
 
pbettsAuthor Commented:
... 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
 
BrianWrenCommented:
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
 
pbettsAuthor Commented:
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
 
MikeRenzCommented:
how about


  UCase(cStr(chr$(___)))

0
 
BrianWrenCommented:
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
 
BrianWrenCommented:
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
 
BelieverCommented:
Brian: Neato!  How'd you get those bullets? <grin>  Seriously!
0
 
BrianWrenCommented:
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
 
ornicarCommented:
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
 
pbettsAuthor Commented:
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
 
pbettsAuthor Commented:
?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
 
BrianWrenCommented:
Great!  I was wondering about the outcome and solutions on this one...

Brian
0
 
pbettsAuthor Commented:
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
 
BrianWrenCommented:
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
 
pbettsAuthor Commented:
Thanks Brian, I suppose this was in the FAQ somewhere..... but hey.... who gets the time :)

Peter Betts
0
All Courses

From novice to tech pro — start learning today.