Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error "Can't find project or library" 2

Status
Not open for further replies.

BrenoAguiar

IS-IT--Management
Feb 8, 2005
81
US
I have this code to limit the number of characteres in the text box:

Private Sub LimitChange(ctl As Control, iMaxLen As Integer)
On Error GoTo Err_LimitChange

If Len(ctl.Text) > iMaxLen Then
MsgBox "Limited to " & iMaxLen & " characters.", vbExclamation, "Too long"
ctl.Text = Left(ctl.Text, iMaxLen)
ctl.SelStart = iMaxLen
End If

Exit_LimitChange:
Exit Sub
End Sub

WHERE "imaxlen" is here:

Private Sub addnt_KeyPress(KeyAscii As Integer)
Call LimitKeyPress(Me.addnt, 460, KeyAscii)
End Sub

The error I'm getting highlights the "Left(ctl.Text, iMaxLen) when you click the "Debug" button.
when I run this on My machine works just great. But If I run this on My server, this error 3075 pops up. Also won't recognize the chr(13) or chr(24).

Any thoughts?
 
I'm a little confused. You seem to be passing three parameters to a sub that only takes two.

 
It works like that:

First you run:

Private Sub addnt_KeyPress(KeyAscii As Integer)
Call LimitKeyPress(Me.addnt, 460, KeyAscii)
End Sub

Then it calls:

Private Sub LimitChange(ctl As Control, iMaxLen As Integer)
On Error GoTo Err_LimitChange

If Len(ctl.Text) > iMaxLen Then
MsgBox "Limited to " & iMaxLen & " characters.", vbExclamation, "Too long"
ctl.Text = Left(ctl.Text, iMaxLen)
ctl.SelStart = iMaxLen
End If

Exit_LimitChange:
Exit Sub
End Sub



On sub will call the other. why it would take only three paramenters? It works fine on my machine but when I use it from my server it gives me the error. Weird ha?
 
Checks the references on your server:
when in VBE, menu Tools -> References ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
With the sample that you have provided the event procedure

issues this command:
Call LimitKeyPress(Me.addnt, 460, KeyAscii)

Where does this sub fit in?
Private Sub LimitChange(ctl As Control, iMaxLen As Integer)

If this is the sub that is called:

1) It has a different name and
2) It does not take the KeyAscii parameter

Hence: I am a little confused.

More so now that you say it works on one machine and not another.


 
What versions of access are each respective computer using?

-Bean
"Everything should be made as simple as possible, but not simpler." -Albert Einstein
 
My bad...
here is the "Limit Key Press" Sub:

Private Sub LimitKeyPress(ctl As Control, iMaxLen As Integer, KeyAscii As Integer)
On Error GoTo Err_LimitKeyPress


If Len(ctl.Text) - ctl.SelLength >= iMaxLen Then
If KeyAscii <> vbKeyBack Then
KeyAscii = 0
Beep
End If
End If

Exit_LimitKeyPress:
Exit Sub

Err_LimitKeyPress:
MsgBox Err.Description, "LimitKeyPress()"
Resume Exit_LimitKeyPress
End Sub


The "LimitChange" sub is on the "Change event"..

I found a reference Lybrary Missing on the server :
CPS Thumbnail ctrl 1.0 type library

I'm trying to install it now on the server too but can't find the file.
 
Now I understand.

I think PHV's suggestions is therefore the most likely cause of the problem.
 
That was IT. the library file got lost some how from the server..

Thanks again Guys!
 
Is the chr(13) and chr(24) also fixed?

If not, then some comments...

Keypress is a bit peculiar (or perhaps not so intuitive as one wishes). See - while in a control, and you pass a keystroke that's going to change focus to the next control, this control receives the keydown event, then normally the focus goes to the next control in the tab order, which receives the keystroke in it's [/b]keypress[/b] event;-)

Also, the KeyPress is more for printable characters, so a lot of keystrokes are simply not catched at all (for instance, backspace is trapped, but not delete)...

Try using the KeyDown event in stead, and check the KeyCode (the KeyCode constants can be found in the help files)

Roy-Vidar
 
Roy,

It actually fixed the problem of the chr(13) and chr(24). But if this reference is not activated (CPS Thumbnail ctrl 1.0 type library), it won't take the chr(13) for example.

Thanks a bunch
Breno
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top