This code will grab the database path and split it into the path and the
filename.
Neil
Dim strFullPath As String
strFullPath = Me.Application.CurrentDb.Name
Dim strFilePath As String
Dim strFileName As String
Call parseFilePathAndName(strFullPath , strFilePath, strFileName)
'---------------------------------------------------------------------------------------
' Routine Name : parseFilePathAndName
' Creation Date : 08/15/2005 09:44
' Last Mod. Date : 08/15/2005
' Routine Type : Sub
' In Parameters : ByVal strFullPath As String - The database name and path.
' Out Parameters : ByRef strDbPath As String - Database path only.
' ByRef strDbName As String - Database name only.
' IN/Out Params :
' Opt. Params :
' Return Type :
' Purpose : This routine takes a file path and breaks it into a path
and a file name.
'---------------------------------------------------------------------------------------
Private Sub parseFilePathAndName(ByVal strFullPath As String, ByRef strDbPath
As String, ByRef strDbName As String)
If strFullPath = "" Or IsNull(strFullPath) Then
Call errCustom("Invalid parameter condition, strFullPath,
parseFilePathAndName()")
Else
' All parameters are in good form. Continue with subroutine.
' Count Slashes
Dim intCurPos As Integer
Dim intTempPos As Integer
Dim strSearchCharacter As String
strSearchCharacter = "\"
Do
intCurPos = intTempPos
If intTempPos = 0 Then
' Initial instance
intTempPos = InStr(1, strFullPath, strSearchCharacter, 1)
Else
intTempPos = InStr(intCurPos + 1, strFullPath,
strSearchCharacter, 1)
End If ' If intTempPos = 0 Then
Loop Until intTempPos = 0
' intCurPos now contains the last location of the "\" key in the string.
' Trim the path out so only the db name remains.
Dim strPath As String
Dim strTempName As String
strPath = Left(strFullPath, intCurPos)
strTempName = Right(strFullPath, Len(strFullPath) - intCurPos)
strDbPath = strPath
strDbName = strTempName
End If ' Parameter Checks
End Sub
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of John Viescas
Sent: Monday, June 19, 2006 8:54 AM
To: [email protected]
Subject: RE: [ms_access] CurDir help please
Neil-
See code I posted that uses CurrentDb.Name but extracts just the Path from
it. The Name property includes the full path *and* the database file name.
John Viescas, author
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
Running Microsoft Access 2000
SQL Queries for Mere Mortals
http://www.viescas. <http://www.viescas.com/> com/
(Paris, France)
For the inside scoop on Access 2007, see:
http://blogs. <http://blogs.msdn.com/access/> msdn.com/access/
_____
From: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com [mailto:
[EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com] On Behalf
Of Squires, Neil
Sent: Monday, June 19, 2006 4:18 PM
To: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com
Subject: RE: [ms_access] CurDir help please
Guy's, I think this may be the code you are looking for.
Dim FullPath As String
FullPath = Me.Application.CurrentDb.Name
Neil
-----Original Message-----
From: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com
[mailto:[EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com]On
Behalf Of John Viescas
Sent: Sunday, June 18, 2006 10:58 PM
To: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com
Subject: RE: [ms_access] CurDir help please
Brett-
Shouldn't work. If I go to A97 Immediate Window and type:
?Application.CurrentProject.Path
.. I get "Method or Data Member not found."
How did you make the "A97" copy, and how did you compile it?
John Viescas, author
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
Running Microsoft Access 2000
SQL Queries for Mere Mortals
http://www.viescas. < http://www.viescas. < http://www.viescas.
<http://www.viescas.com/> com/> com/>
com/
(Paris, France)
For the inside scoop on Access 2007, see:
http://blogs. < http://blogs. < http://blogs. <http://blogs.msdn.com/access/>
msdn.com/access/>
msdn.com/access/> msdn.com/access/
_____
From: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com
[mailto: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com] On
Behalf
Of Brett Collings
Sent: Sunday, June 18, 2006 11:06 PM
To: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com
Subject: Re: [ms_access] CurDir help please
Now that's interesting! One of my clients has 10 machines on XP and
one on A97. The reference to all my form and report graphics is
Application.CurrentProject.Path & "/graphics/"
I've made an A97 copy for them and it seems to work. I wonder if I just
got lucky?
Brett
John Viescas wrote:
> Brett-
>
> The CurrentProject property doesn't exist in Access 97.
>
> John Viescas, author
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> Running Microsoft Access 2000
> SQL Queries for Mere Mortals
> http://www.viescas. < http://www.viescas. < http://www.viescas.
< http://www.viescas. <http://www.viescas.com/> com/> com/> com/> com/ <
http://www.viescas.
< http://www.viescas. < http://www.viescas. < http://www.viescas.
<http://www.viescas.com/> com/> com/>
com/> com/>
> (Paris, France)
> For the inside scoop on Access 2007, see:
> http://blogs. < http://blogs. < http://blogs.
< http://blogs. <http://blogs.msdn.com/access/> msdn.com/access/>
msdn.com/access/> msdn.com/access/>
msdn.com/access/
< http://blogs. < http://blogs. < http://blogs.
< http://blogs. <http://blogs.msdn.com/access/> msdn.com/access/>
msdn.com/access/> msdn.com/access/>
msdn.com/access/>
>
> _____
>
> From: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com
<mailto:ms_access%40yahoogroups.com>
> [mailto:[EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com
> <mailto:ms_access%40yahoogroups.com>] On Behalf
> Of Brett Collings
> Sent: Sunday, June 18, 2006 10:12 PM
> To: [EMAIL PROTECTED] <mailto:ms_access%40yahoogroups.com> ps.com
<mailto:ms_access%40yahoogroups.com>
> Subject: Re: [ms_access] CurDir help please
>
> I don't have the reference here so this is aircode
> Application.CurrentProject.Path
> is I think the object that returns the path of the currently open
> database.
>
> Brett
>
> Ilona Wright wrote:
>
> > Hi John,
> > I am using the CurDir function to return the current path.
> > I am expecting the path of the .mdb using the function, but it
> returns the
> > ACCESS Default Database Folder.
> > Can you please tell me how to determine the current path?
> >
> > I am using Acces 97. What I am trying to do is establish links to
> > tables on
> > opening my switchboard form. The data tables are in a separate
> databse to
> > the application software, but I expect the tables database to reside
> > in the
> > same folder as the application software database. So, if the switchboard
> > knows where it is, it can establish the links to the data tables. I
> > want the
> > linking to be hidden from the user.
> > I hope this makes sense.
> > Thank you again in advance
> > Ilona
> >
> > [Non-text portions of this message have been removed]
> >
> >
>
> --
> Brett Collings
> Strengthening Families Administrator
> D2D 46422
> DDI (04) 916 3422
>
> -------------------------------
> This email message and any attachment(s) is intended only for the
> person(s) or entity(entities) to whom it is addressed. The
> information it contains may be classified as IN CONFIDENCE and may be
> legally privileged. If you are not the intended recipient any use,
> disclosure or copying of the message or attachment(s) is strictly
> prohibited. If you have received this message in error please
> notify us immediately and destroy it and any attachment(s).
> Thank you. The Ministry of Social Development accepts no
> responsibility for changes made to this message or to any
> attachment(s) after transmission from the Ministry.
> -------------------------------
>
> [Non-text portions of this message have been removed]
>
> [Non-text portions of this message have been removed]
>
>
--
Brett Collings
Strengthening Families Administrator
D2D 46422
DDI (04) 916 3422
-------------------------------
This email message and any attachment(s) is intended only for the
person(s) or entity(entities) to whom it is addressed. The
information it contains may be classified as IN CONFIDENCE and may be
legally privileged. If you are not the intended recipient any use,
disclosure or copying of the message or attachment(s) is strictly
prohibited. If you have received this message in error please
notify us immediately and destroy it and any attachment(s).
Thank you. The Ministry of Social Development accepts no
responsibility for changes made to this message or to any
attachment(s) after transmission from the Ministry.
-------------------------------
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/q7folB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ms_access/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/