Dustin Stanley
asked on
Ms Access CurrentProject.Path Code Alter For a Split Front End Backend Database
How can I alter this to use on a split access database?
It just returns the Front End path not the Backend.
It just returns the Front End path not the Backend.
Public Function GetDBPath() As String
GetDBPath = CurrentProject.Path & "\"
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
author wants path for BE
Ignore my post
ASKER
THANK YOU ALL!
WHERE = Expected End of statement.
Yes exactly!
Was getting it in the ball park but not exactly.
Let me post all the previous code and maybe this will help more.
Public Function GetDBPath(sTblName As String)
Dim rs As Recordset
Dim sSQL As String
sSQL = "SELECT Database"
FROM MSysObjects WHERE Name='" & sTblName & "';"
Set rst = CurrentDb.OpenRecordset(sSQL)
If Not rs.EOF Then
ConnectStringOfLinkedTable= rs!Database
End If
rs.Close
End Function
WHERE = Expected End of statement.
By "Backend (database)" do you mean you have two MS-Access databases, a "front-end" (with Forms), & a "back-end" with tables, with linked tables in the "front-end" to the "back-end" database?
Yes exactly!
strBackend_Path = Mid$(CurrentDB.TableDefs("Table1").C onnect, 11)
Was getting it in the ball park but not exactly.
Let me post all the previous code and maybe this will help more.
Image126.Picture = GetProductImageFileNm & Forms!frmSKUsEntry!sbfrmProductImages.Form!ProductImageFileNm
End Sub
Public Function GetProductImageFileNm() As String
GetProductImageFileNm = GetDBPath & "images\"
End Function
Public Function GetDBPath() As String
GetDBPath = CurrentProject.Path & "\"
End Function
Was getting it in the ball park but not exactly.
Go on, please give me a clue what you did see in the strBackend_Path variable.
Thanks.
ASKER
Go on, please give me a clueCan't open the file'\\Sur1-PC\Sur Database\Sur Database_BEaccdbimages\'
Which it can't open a file that doesn't exist.
I need it to return:\\Sur1-PC\Sur Database\Images\
ASKER
Works Great Thanks!
Public Function GetDBPath() As String
Dim GetDBPathh As String
Dim I As Integer
GetDBPath = Mid(DBEngine.Workspaces(0).Databases(0).TableDefs("Assemblies").Connect, 11)
For I = Len(GetDBPath) To 1 Step -1
If Mid(GetDBPath, I, 1) = "\" Then
GetDBPath = Left(GetDBPath, I)
Exit For
End If
Next
End Function
ASKER
Thank you!
This will include the name of the back end db.
Public Function GetDBPath() As String
GetDBPath = Replace(CurrentDb.TableDef s("SomeLinkedTableNameHere").Connect, ";DATABASE=", "")
End Function
This is without the db name
Public Function GetDBPath() As String
GetDBPath = Replace(CurrentDb.TableDef s("SomeLinkedTableNameHere").Connect, ";DATABASE=", "")
'Remove db name
GetDBPath = left(GetDBPath ,InStrRev (GetDBPath,"\" ))
End Function
Public Function GetDBPath() As String
GetDBPath = Replace(CurrentDb.TableDef
End Function
This is without the db name
Public Function GetDBPath() As String
GetDBPath = Replace(CurrentDb.TableDef
'Remove db name
GetDBPath = left(GetDBPath ,InStrRev (GetDBPath,"\" ))
End Function
ASKER
Thank you DatabaseMX for the additional info. I had figured it out and closed the question just a second ago or I would have included this in the assisted answers. But anyone in the future viewing this will defiantly benefit from that info! Thanks!
No need for a loop :-)
ASKER
No need for a loop :-)
I see Thank you!
Public Function GetDBPath() As String
GetDBPath = CurrentProject.FullName & "\"
End Function