Undefined Function "DIR" in expression

  • Thread starter Ronald W. Roberts
  • Start date
R

Ronald W. Roberts

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
 
D

Dirk Goldgar

Ronald W. Roberts said:
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

I suspect that those computers where it isnt working have Jet running in
sandbox mode. See this article:

http://support.microsoft.com/default.aspx?scid=kb;en-us;294698
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top