A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

app.path i dunno whats wrong HELP newbie here?



 
 
Thread Tools Display Modes
  #1  
Old August 28th, 2006, 10:45 AM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 5
Default app.path i dunno whats wrong HELP newbie here?

AM USING THIS for
now----------------------------------------------------------------------------------------
Public Sub OpenDBConnection()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
strconek = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
Files\balik sa dati\data\MFMS.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient
conn.Open strconek
End Sub
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
ICANT USE THIS
Public Sub OpenDBConnection()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
strconek = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
app.path & "\data\MFMS.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient
conn.Open strconek
End Sub
-----------------------------------------------------------------------------------------
the error is:

  #2  
Old August 28th, 2006, 12:20 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default app.path i dunno whats wrong HELP newbie here?

If you're trying to use this from within Access, there is no App object in
Access, so App.Path will (naturally) fail.

Assuming you're using Access 2000 or newer, use CurrentApplication.Path
instead.

BTW, note that both App.Path and CurrentApplication.Path have an annoying
little "feature". If the file is in the root of a drive, what's returned
will have a terminating slash: E:\, not simply E:. That means that something
like

strconek = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
App.Path & "\data\MFMS.mdb;Persist Security Info=False"

or

strconek = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
CurrentApplication.Path & "\data\MFMS.mdb;Persist Security Info=False"

will fail, as you'll end up with two slashes in a row.

To get around this, try:

Dim strPath As String

strPath = CurrentApplication.Path
If Right$(strPath, 1) "\" Then
strPath = strPath & "\"
End If
strconek = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strPath & "\data\MFMS.mdb;Persist Security Info=False"





--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


wrote in message
ups.com...
AM USING THIS for
now----------------------------------------------------------------------------------------
Public Sub OpenDBConnection()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
strconek = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
Files\balik sa dati\data\MFMS.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient
conn.Open strconek
End Sub
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
ICANT USE THIS
Public Sub OpenDBConnection()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
strconek = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
app.path & "\data\MFMS.mdb;Persist Security Info=False"
conn.CursorLocation = adUseClient
conn.Open strconek
End Sub
-----------------------------------------------------------------------------------------
the error is:



  #3  
Old August 28th, 2006, 04:07 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 1,164
Default app.path i dunno whats wrong HELP newbie here?

"Douglas J. Steele" wrote in
message

Assuming you're using Access 2000 or newer, use
CurrentApplication.Path instead.


CurrentProject.Path, I think Doug means.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #4  
Old August 28th, 2006, 05:08 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default app.path i dunno whats wrong HELP newbie here?

"Dirk Goldgar" wrote in message
...
"Douglas J. Steele" wrote in
message

Assuming you're using Access 2000 or newer, use
CurrentApplication.Path instead.


CurrentProject.Path, I think Doug means.


Thanks, Dirk. I've only got Access 97 installed on this machine, so I was
going from memory.

For the record, in Access 97 or earlier, you'd use

Left$(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir$(CurrentDb.Name)))

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:18 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.