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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error for String$ 2

Status
Not open for further replies.

Bresart

Programmer
Feb 14, 2007
314
ES
Hi, in a DB that registers a try version of DBPix ( the code

strClassName = String$(MAXLEN, 0): lngClassLen = MAXLEN


gives the error

"Compilation error: the project or the library can't be found."

with String$ highlighted.


It seems like a library must be included. Which would be the code to be added?

Thanks.
 
In the VBE window: menu Tools -> References ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you PHV missinglinq.

I've seen there's no way to go around of a references error in a workstation different to that in which the file was created, in case of MDE file.

I'll attempt to avoid the MDE conversion.

 
Why not CStr() ?

Always remember that you're unique. Just like everyone else.
 
Thanks genomon.

Anyway the best option would be not depending of any dll or library, in other words, not depending of access references.

1. Can i know which references is the MDB using (better said, is the MDB code needing) and replacing this code for other that doesn't need any reference?

2. Am i right thinking that there's some no-removable references?

3. Does it mean that the MDB-MDE will always be subject to references location and version problems, if the code has any statement that needs a reference but i can't relate it with the selected references because they are un-removable?
 

1. Yes. Remove one at a time and Debug-->Compile. If no error message appears, then it was not needed. If you remove a reference you need do

Dim rst As Object 'ADODB.Recordset
Set rst = CreateObject("ADODB.Recordset")

2. Yes. Visual Basic For Applications is one and Microsoft Access x.0 Object Library the other.

3. No. If you do #1 then those of #2 are always there. The second has to do with the installed version of MSACCESS.EXE which does have backwards [only] compatibility.
 
Thank you, JerryKlmns.

I have done 1) and there's a reference needed other than 2): Microsoft ActiveX Data Objects 2.1 Library. It gives the error

Compilation error: user defined type hasn't be defined.

for the code

Dim cn As ADODB.Connection

1. I haven't understood your suggestion (1) for handling with needed references, since for example in this case what i need is a connection, not a recordset. How can this compilation error be fixed?

2. About 3), i understand that the first needed reference (Visual Basic For Applications) won't give any reference problem, but perhaps the second needed reference (Microsoft Access x.0 - in this case 9.0- Object Library) would give an error in versions of MsAccess.exe later than MS Access 2000 which i am using, and the best thing would be to check with that later versions. Am i right?
 
Where does the code that's erroring out

Code:
strClassName = String$(MAXLEN, 0):  lngClassLen = MAXLEN

appear? I've downloaded the demo DBPix app and can't find the code anywhere in it.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I perhaps will have references problems with this, in an independent module:

Public Declare Function GetSystemDirectory Lib "kernel32.dll" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

1. Can anybody say if this file reference will give version or location problems in a workstation other than the one i am working?

2. If it will, can the function GetSystemDirectory be replaced by a non file and non reference dependent code?

3. References the application needs are three:

A. Microsoft ActiveX Data Objects 2.1 Library
B. Visual Basic For Applications
C. Microsoft Access 9.0 Object Library

Removing A. gives the error

Compilation error: user defined type hasn't be defined.

for the code

Dim cn As ADODB.Connection

Does anybody know how can this compilation error be fixed?

4. Will B. and C. references give any location or version problem in other workstation, or with other MS Access version than 2000?

Thanks for any help given.

 
Have you tried Environ("SystemRoot") ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, PHV.

It gives the error 'Types don't match'.

The code is inside a function, as follows:



Const MaxPathLen = 255

Public Function GetSysDir() As String
Dim SysDir As String
Dim StringLen As Integer
SysDir = Space(MaxPathLen)
StringLen = GetSystemDirectoryA(SysDir, MaxPathLen)
GetSysDir = Left(SysDir, StringLen)
End Function

 
About 3., i have replaced the code like JerryKlmns said:

Dim rst As Object 'ADODB.Recordset
Set rst = CreateObject("ADODB.Recordset")


But after, the code

rst.Open strQuery, CurrentProject.Connection, _
adOpenStatic, , adCmdUnknown

gives the error: Variable not defined, for adOpenStatic.

Any other way of opening the rst?
 
I meant this:
Code:
Public Function GetSysDir() As String
    GetSysDir = Environ("SystemRoot")
End Function

Variable not defined, for adOpenStatic
You have to reference the Microsoft ActiveX Data Objects 2.x Library

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, PHV. It works.

I was trying to not referencing the Microsoft ActiveX Data Objects 2.x Library. Is there any way of opening the recordset avoiding the error without the reference?
 
Use late binding and the true value of the adXXX constants.
eg 3 instead of adOpenStatic

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, PHV.

THe line

cn.Execute strQuery

gives the error "Not allowed operation if object is closed."

Any work around that error?



strQuery = "INSERT INTO tbl..."
Dim cn As Object
Set cn = CreateObject("ADODB.Connection")
cn.Execute strQuery
 
You need to open the connection to use it.

When everything is coming your way, you're in the wrong lane.
 
Thanks genomon.

Which would be the code for opening the connection?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top