While looking at the forum the other day I found an entry that showed how to return the path of the current database.
This is the code.........
Dim db As DAO.Database
Dim strPath As String
Dim intCharacter As Integer
Set db = CurrentDb
strPath = db.Name
intCharacter = InStrRev(strPath, "\")
strPath = Left(strPath, intCharacter)
'Use this code block to retrieve the path or the current database.
There were 2 problems... I've fixed one but I'll explain in case the second is similar but I just can't see it.
The first line of code....
Dim db As DAO.Database
the DAO.Database gave an error message "User-defined type not defined"
I fixed this by going into Tools/References in the VBA code window and ticking the item
Microsoft DAO 3.6 Object Library
The problem I can't resolve is in the last line of code...
strPath = Left(strPath, intCharacter)
I get an error message saying "Ambiguous term" in respect of the Left 'function'
Now as I understand it this is an intrinsic function of VBA so why does it not recognise it. It doesn't recognise 'Right' either, but I'm OK with things like 'Len' and 'StrConv'
Am I missing another reference? I have tried ticking all the items that looked anything like possible but I've not found one that works.
Any Ideas will be graetfully recieved.
[This message has been edited by Sprocket (edited 04-16-2002).]
[This message has been edited by Sprocket (edited 04-16-2002).]
This is the code.........
Dim db As DAO.Database
Dim strPath As String
Dim intCharacter As Integer
Set db = CurrentDb
strPath = db.Name
intCharacter = InStrRev(strPath, "\")
strPath = Left(strPath, intCharacter)
'Use this code block to retrieve the path or the current database.
There were 2 problems... I've fixed one but I'll explain in case the second is similar but I just can't see it.
The first line of code....
Dim db As DAO.Database
the DAO.Database gave an error message "User-defined type not defined"
I fixed this by going into Tools/References in the VBA code window and ticking the item
Microsoft DAO 3.6 Object Library
The problem I can't resolve is in the last line of code...
strPath = Left(strPath, intCharacter)
I get an error message saying "Ambiguous term" in respect of the Left 'function'
Now as I understand it this is an intrinsic function of VBA so why does it not recognise it. It doesn't recognise 'Right' either, but I'm OK with things like 'Len' and 'StrConv'
Am I missing another reference? I have tried ticking all the items that looked anything like possible but I've not found one that works.
Any Ideas will be graetfully recieved.
[This message has been edited by Sprocket (edited 04-16-2002).]
[This message has been edited by Sprocket (edited 04-16-2002).]