473,395 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Undefined Function "DIR" in expression

I'm not sure where this routine came from,
but here is the problem. On certian computers
this error occurs, but it does not on others.
The error is: "Undefined Function "DIR" in expression".

The form open event calls the CheckandRepairLinks
without a varable being passed it it.

CheckandRepairLinks

The instruction that fails is the Set instruction
pointing to the DIR instruction.

Set RecordSetOfLinks = dbs.OpenRecordset(LinksToPathsSQL)

I really don't know what to do with this because it
is saying it can't find the DOS command "DIR'. In other
forms I have the DIR command and I don't get the error.
Also, I checked and there are no missing references.

Below is a snapshot of the Checkand RepairLinks procedure.

Private Sub CheckandRepairLinks(Optional ByRef dbs As
Database)

' An SQL String To Return a List of Linked DataBases Files
' which cannot be found
Const LinksToPathsSQL As String = _
"SELECT TOP 1 CStr(DataBase) AS DatabaseFile " _

& "FROM MSysObjects " _
& "WHERE Connect Is Null " _
& "AND Left(Name,1) <> '~' " _
& "AND Type = 6 " _
& "AND Len(Dir(CStr(DataBase))) = 0 " _
& "ORDER BY CStr(DataBase);"

' Message to be sent on Cancel or Exit being chosen from
File Dialog Box
Const FileNotChosenMessage As String = _
"No File was Chosen!" _
& vbCrLf _
& "Click OK to Continue " _
& vbCrLf _
& "Click Cancel to Exit Link Checking"

Dim DbsWasPassed As Boolean
Dim NameNotIn As String
Dim RecordSetOfLinks As Recordset
Dim OldPath As String
Dim ButtonSelected As Long
Dim NewPath As String
Dim TableDefinition As TableDef

' display relinking message
'lblVerifyingLocationofLinkedTables.Visible = True
DoEvents

If dbs Is Nothing Then
Set dbs = DBEngine(0)(0)
Else
' note if the DataBase was passed
DbsWasPassed = True
End If

' Dummy NameNotIn
NameNotIn = "'" & Chr(255) & "'"

' refresh the tabledefs collection
dbs.TableDefs.Refresh

Do

' Get the first linked lost mdb
Set RecordSetOfLinks = Nothing
' MsgBox LinksToPathsSQL, vbCritical, "Link To Path
SQL"
Set RecordSetOfLinks =
dbs.OpenRecordset(LinksToPathsSQL)

-- Cut
Thanks,
Ron
--
Ronald W. Roberts
Roberts Communication
rw*******************@robcom.com
To reply remove "_at_robcom_dot_com"
Nov 12 '05 #1
3 6073
"Ronald W. Roberts" <rw*@robcom.com> wrote in
news:3F***************@robcom.com:
I'm not sure where this routine came from,
but here is the problem. On certian computers
this error occurs, but it does not on others.
The error is: "Undefined Function "DIR" in expression".

The form open event calls the CheckandRepairLinks
without a varable being passed it it.

CheckandRepairLinks

The instruction that fails is the Set instruction
pointing to the DIR instruction.

Set RecordSetOfLinks = dbs.OpenRecordset(LinksToPathsSQL)

I really don't know what to do with this because it
is saying it can't find the DOS command "DIR'. In other
forms I have the DIR command and I don't get the error.
Also, I checked and there are no missing references.

Below is a snapshot of the Checkand RepairLinks procedure.

Private Sub CheckandRepairLinks(Optional ByRef dbs As
Database)

' An SQL String To Return a List of Linked DataBases Files
' which cannot be found
Const LinksToPathsSQL As String = _
"SELECT TOP 1 CStr(DataBase) AS DatabaseFile " _

& "FROM MSysObjects " _
& "WHERE Connect Is Null " _
& "AND Left(Name,1) <> '~' " _
& "AND Type = 6 " _
& "AND Len(Dir(CStr(DataBase))) = 0 " _
& "ORDER BY CStr(DataBase);"

' Message to be sent on Cancel or Exit being chosen from
File Dialog Box
Const FileNotChosenMessage As String = _
"No File was Chosen!" _
& vbCrLf _
& "Click OK to Continue " _
& vbCrLf _
& "Click Cancel to Exit Link Checking"

Dim DbsWasPassed As Boolean
Dim NameNotIn As String
Dim RecordSetOfLinks As Recordset
Dim OldPath As String
Dim ButtonSelected As Long
Dim NewPath As String
Dim TableDefinition As TableDef

' display relinking message
'lblVerifyingLocationofLinkedTables.Visible = True
DoEvents

If dbs Is Nothing Then
Set dbs = DBEngine(0)(0)
Else
' note if the DataBase was passed
DbsWasPassed = True
End If

' Dummy NameNotIn
NameNotIn = "'" & Chr(255) & "'"

' refresh the tabledefs collection
dbs.TableDefs.Refresh

Do

' Get the first linked lost mdb
Set RecordSetOfLinks = Nothing
' MsgBox LinksToPathsSQL, vbCritical, "Link To Path
SQL"
Set RecordSetOfLinks =
dbs.OpenRecordset(LinksToPathsSQL)

-- Cut
Thanks,
Ron
--
Ronald W. Roberts
Roberts Communication
rw*******************@robcom.com
To reply remove "_at_robcom_dot_com"


Perhaps, you have a missing or broken reference on those machines where
"Dir" is raising an error?

The origin of the code ... do you think it might be your responsibility to
find out what it is? ... and as a courtesy credit the author in your code
with a comment?

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2
Lyle Fairfield wrote:
"Ronald W. Roberts" <rw*@robcom.com> wrote in
news:3F***************@robcom.com:
I'm not sure where this routine came from,
but here is the problem. On certian computers
this error occurs, but it does not on others.
The error is: "Undefined Function "DIR" in expression".

The form open event calls the CheckandRepairLinks
without a varable being passed it it.

CheckandRepairLinks

The instruction that fails is the Set instruction
pointing to the DIR instruction.

Set RecordSetOfLinks = dbs.OpenRecordset(LinksToPathsSQL)

I really don't know what to do with this because it
is saying it can't find the DOS command "DIR'. In other
forms I have the DIR command and I don't get the error.
Also, I checked and there are no missing references.

Below is a snapshot of the Checkand RepairLinks procedure.

Private Sub CheckandRepairLinks(Optional ByRef dbs As
Database)

' An SQL String To Return a List of Linked DataBases Files
' which cannot be found
Const LinksToPathsSQL As String = _
"SELECT TOP 1 CStr(DataBase) AS DatabaseFile " _

& "FROM MSysObjects " _
& "WHERE Connect Is Null " _
& "AND Left(Name,1) <> '~' " _
& "AND Type = 6 " _
& "AND Len(Dir(CStr(DataBase))) = 0 " _
& "ORDER BY CStr(DataBase);"

' Message to be sent on Cancel or Exit being chosen from
File Dialog Box
Const FileNotChosenMessage As String = _
"No File was Chosen!" _
& vbCrLf _
& "Click OK to Continue " _
& vbCrLf _
& "Click Cancel to Exit Link Checking"

Dim DbsWasPassed As Boolean
Dim NameNotIn As String
Dim RecordSetOfLinks As Recordset
Dim OldPath As String
Dim ButtonSelected As Long
Dim NewPath As String
Dim TableDefinition As TableDef

' display relinking message
'lblVerifyingLocationofLinkedTables.Visible = True
DoEvents

If dbs Is Nothing Then
Set dbs = DBEngine(0)(0)
Else
' note if the DataBase was passed
DbsWasPassed = True
End If

' Dummy NameNotIn
NameNotIn = "'" & Chr(255) & "'"

' refresh the tabledefs collection
dbs.TableDefs.Refresh

Do

' Get the first linked lost mdb
Set RecordSetOfLinks = Nothing
' MsgBox LinksToPathsSQL, vbCritical, "Link To Path
SQL"
Set RecordSetOfLinks =
dbs.OpenRecordset(LinksToPathsSQL)

-- Cut
Thanks,
Ron
--
Ronald W. Roberts
Roberts Communication
rw*******************@robcom.com
To reply remove "_at_robcom_dot_com"


Perhaps, you have a missing or broken reference on those machines where
"Dir" is raising an error?

The origin of the code ... do you think it might be your responsibility to
find out what it is? ... and as a courtesy credit the author in your code
with a comment?

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)


It's not a broken reference, that has already bee checked.

Ron
--
Ronald W. Roberts
Roberts Communication
rw*******************@robcom.com
To reply remove "_at_robcom_dot_com"
Nov 12 '05 #3
Hi Ronald,

I am able to reproduce the error message you show if I have the registry setting for the
sandbox mode set to either 1 or 3. If the setting is at the default value of 2, I do not
generate this error.

Microsoft Jet 4.0 Expression Can Execute Unsafe Visual Basic for Applications Functions
http://support.microsoft.com/default.aspx?kbid=294698

At the end of your example, you indicated: -- Cut
Would you be so kind as to supply the rest of the code. I am very much interested in
receiving a sample database with this functionality.

Tom
____________________________________________

"Ronald W. Roberts" <rw*@robcom.com> wrote in message news:3F***************@robcom.com...

I'm not sure where this routine came from,
but here is the problem. On certian computers
this error occurs, but it does not on others.
The error is: "Undefined Function "DIR" in expression".

The form open event calls the CheckandRepairLinks
without a varable being passed it it.

CheckandRepairLinks

The instruction that fails is the Set instruction
pointing to the DIR instruction.

Set RecordSetOfLinks = dbs.OpenRecordset(LinksToPathsSQL)

I really don't know what to do with this because it
is saying it can't find the DOS command "DIR'. In other
forms I have the DIR command and I don't get the error.
Also, I checked and there are no missing references.

Below is a snapshot of the Checkand RepairLinks procedure.

Private Sub CheckandRepairLinks(Optional ByRef dbs As
Database)

' An SQL String To Return a List of Linked DataBases Files
' which cannot be found
Const LinksToPathsSQL As String = _
"SELECT TOP 1 CStr(DataBase) AS DatabaseFile " _

& "FROM MSysObjects " _
& "WHERE Connect Is Null " _
& "AND Left(Name,1) <> '~' " _
& "AND Type = 6 " _
& "AND Len(Dir(CStr(DataBase))) = 0 " _
& "ORDER BY CStr(DataBase);"

' Message to be sent on Cancel or Exit being chosen from
File Dialog Box
Const FileNotChosenMessage As String = _
"No File was Chosen!" _
& vbCrLf _
& "Click OK to Continue " _
& vbCrLf _
& "Click Cancel to Exit Link Checking"

Dim DbsWasPassed As Boolean
Dim NameNotIn As String
Dim RecordSetOfLinks As Recordset
Dim OldPath As String
Dim ButtonSelected As Long
Dim NewPath As String
Dim TableDefinition As TableDef

' display relinking message
'lblVerifyingLocationofLinkedTables.Visible = True
DoEvents

If dbs Is Nothing Then
Set dbs = DBEngine(0)(0)
Else
' note if the DataBase was passed
DbsWasPassed = True
End If

' Dummy NameNotIn
NameNotIn = "'" & Chr(255) & "'"

' refresh the tabledefs collection
dbs.TableDefs.Refresh

Do

' Get the first linked lost mdb
Set RecordSetOfLinks = Nothing
' MsgBox LinksToPathsSQL, vbCritical, "Link To Path
SQL"
Set RecordSetOfLinks =
dbs.OpenRecordset(LinksToPathsSQL)

-- Cut
Thanks,
Ron
--
Ronald W. Roberts
Roberts Communication
rw*******************@robcom.com
To reply remove "_at_robcom_dot_com"

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: MLH | last post by:
Back in '98, Trevor Best posted a 1-liner I consider to be an excellent suggestion: Dir("\testdir\nul") If I have an actual directort named c:\bat and I run Dir("c:\bat\nul") in the immediate...
2
by: VB Programmer | last post by:
I want to write a file to the "secured" dir that is on my website. The full path is: C:\inetpub\wwwroot\MyWebSite\Secured I tried this, but it didn't work: Dim strFileName As String =...
6
by: iris | last post by:
Hi all, What is the simplest way to get a list of all the files in a directory, (on an ipaq) something equivalent to "dir *.* > file" . No need to list directories. I have visual studio 2003...
7
by: per9000 | last post by:
Dear Black Knight, I have no quarrel with you sir Knight, but I must import your parents. SHORT VERSION: I tried three variants of "from ../brave.py import sir_robin", one works. I want...
3
by: Michele Petrazzo | last post by:
Hi, I'm trying a script on a debian 3.1 that has problems on shelve library. The same script work well on a fedora 2 and I don't know why it create this problem on debian: #extract from my code...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
7
by: runsun pan | last post by:
I wanna check if an object is the *arguments* object of a function, is that possible? When we do: typeof(arguments) it always returns "object", doesn't seem to be helpful.
3
by: Sheila Jipping | last post by:
I have a working application which has loaded fine on 2002 and 2003 Access installation. I installed the same app on a 2000 Access and I am receiving "undefined function 'Dir' in expression". ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.