Paths and App.Path 
Author Message
 Paths and App.Path

Quote:

>When I run my VB4 application from within VB,  App.Path
>translates to c:\vb40\projects\myproject\mydb.mdb.
>When I create an executable, then run the executable from
>say c:\mydir, App.Path is assigned the value c:\mydir,
>which is as it should be.
>However, when I reach the line   MainForm.Data1.Refresh,
>I receive the error:
>Runtime error '3024'
>Couldn't find file
>c:\vb40\projects\myproject\mydb.mdb
>Why does this still refer to the project directory, and NOT
>the directory from where it is being executed?
>Below is the code in question:
>  DBName = App.Path & "\" & "mydb.mdb"
>  Set MyWorkspace = Workspaces(0)
>  Set DBProfile = MyWorkspace.OpenDatabase(DBName, False, False)
>  Set MySet1 = DBProfile.OpenRecordset("profilestable")
>  MainForm.Data1.Refresh

Did you fill in the database name as a hardcoded property when you placed the data control on the
form?

- Show quoted text -

Quote:
>Thanks
>    Bernie



Fri, 19 Mar 1999 03:00:00 GMT  
 Paths and App.Path

When I run my VB4 application from within VB,  App.Path
translates to c:\vb40\projects\myproject\mydb.mdb.

When I create an executable, then run the executable from
say c:\mydir, App.Path is assigned the value c:\mydir,
which is as it should be.

However, when I reach the line   MainForm.Data1.Refresh,
I receive the error:

Runtime error '3024'
Couldn't find file
c:\vb40\projects\myproject\mydb.mdb

Why does this still refer to the project directory, and NOT
the directory from where it is being executed?

Below is the code in question:

  DBName = App.Path & "\" & "mydb.mdb"
  Set MyWorkspace = Workspaces(0)
  Set DBProfile = MyWorkspace.OpenDatabase(DBName, False, False)
  Set MySet1 = DBProfile.OpenRecordset("profilestable")
  MainForm.Data1.Refresh

Thanks
        Bernie



Sat, 20 Mar 1999 03:00:00 GMT  
 Paths and App.Path


Barton), wrote these mellifluous words, full of wisdom and thoughtful
reflections:

Quote:
>!<When I run my VB4 application from within VB,  App.Path
>!<translates to c:\vb40\projects\myproject\mydb.mdb.
>!<When I create an executable, then run the executable from
>!<say c:\mydir, App.Path is assigned the value c:\mydir,
>!<which is as it should be.
>!<However, when I reach the line   MainForm.Data1.Refresh,
>!<I receive the error:
>!<Runtime error '3024'
>!<Couldn't find file
>!<c:\vb40\projects\myproject\mydb.mdb
>!<Why does this still refer to the project directory, and NOT
>!<the directory from where it is being executed?
>!<Below is the code in question:
>!<  DBName = App.Path & "\" & "mydb.mdb"
>!<  Set MyWorkspace = Workspaces(0)
>!<  Set DBProfile = MyWorkspace.OpenDatabase(DBName, False, False)
>!<  Set MySet1 = DBProfile.OpenRecordset("profilestable")
>!<  MainForm.Data1.Refresh

Look at the Database property of your datacontrol. I'm afraid, the string is
hardcoded there.

- Show quoted text -

Quote:
>!<Thanks
>!<       Bernie



Sat, 20 Mar 1999 03:00:00 GMT  
 Paths and App.Path

Quote:

> When I run my VB4 application from within VB,  App.Path
> translates to c:\vb40\projects\myproject\mydb.mdb.

> When I create an executable, then run the executable from
> say c:\mydir, App.Path is assigned the value c:\mydir,
> which is as it should be.

> However, when I reach the line   MainForm.Data1.Refresh,
> I receive the error:

> Runtime error '3024'
> Couldn't find file
> c:\vb40\projects\myproject\mydb.mdb

> Why does this still refer to the project directory, and NOT
> the directory from where it is being executed?

> Below is the code in question:

>   DBName = App.Path & "\" & "mydb.mdb"
>   Set MyWorkspace = Workspaces(0)
>   Set DBProfile = MyWorkspace.OpenDatabase(DBName, False, False)
>   Set MySet1 = DBProfile.OpenRecordset("profilestable")
>   MainForm.Data1.Refresh

> Thanks
>         Bernie

Here, I think You're using a data control named 'Data1' in MainForm for
which you must have specified the databasename in the properties list at
design time. So , it's resulting in this error.

This is my interpretation from your code above. Check it out!!!

Phani



Sat, 20 Mar 1999 03:00:00 GMT  
 Paths and App.Path

Quote:


>>When I run my VB4 application from within VB,  App.Path
>>translates to c:\vb40\projects\myproject\mydb.mdb.

>>When I create an executable, then run the executable from
>>say c:\mydir, App.Path is assigned the value c:\mydir,
>>which is as it should be.

>>However, when I reach the line   MainForm.Data1.Refresh,
>>I receive the error:

>>Runtime error '3024'
>>Couldn't find file
>>c:\vb40\projects\myproject\mydb.mdb

>>Why does this still refer to the project directory, and NOT
>>the directory from where it is being executed?

>>Below is the code in question:

>>  DBName = App.Path & "\" & "mydb.mdb"
>>  Set MyWorkspace = Workspaces(0)
>>  Set DBProfile = MyWorkspace.OpenDatabase(DBName, False, False)
>>  Set MySet1 = DBProfile.OpenRecordset("profilestable")
>>  MainForm.Data1.Refresh

>Did you fill in the database name as a hardcoded property when you placed the data control on the
>form?

Yes, that was the problem.


Sat, 20 Mar 1999 03:00:00 GMT  
 Paths and App.Path

Quote:

> When I run my VB4 application from within VB,  App.Path
> translates to c:\vb40\projects\myproject\mydb.mdb.

> When I create an executable, then run the executable from
> say c:\mydir, App.Path is assigned the value c:\mydir,
> which is as it should be.

> However, when I reach the line   MainForm.Data1.Refresh,
> I receive the error:

> Runtime error '3024'
> Couldn't find file
> c:\vb40\projects\myproject\mydb.mdb

> Why does this still refer to the project directory, and NOT
> the directory from where it is being executed?

> Below is the code in question:

>   DBName = App.Path & "\" & "mydb.mdb"
>   Set MyWorkspace = Workspaces(0)
>   Set DBProfile = MyWorkspace.OpenDatabase(DBName, False, False)
>   Set MySet1 = DBProfile.OpenRecordset("profilestable")
>   MainForm.Data1.Refresh

> Thanks
>         BernieHi Bernie,

Am I missing something? I don't see where you are setting the
databaseName property of the data control. If you can set the
databaseName property at design time so you can set up all the bound
controls with the appropriate fields. Then set Enabled = False. When the
program is run have code to set the Data1.DatabaseName = App.Path &
"myfile" and set enabled to true.
HTH


Wed, 24 Mar 1999 03:00:00 GMT  
 Paths and App.Path

Quote:
>However, when I reach the line   MainForm.Data1.Refresh,
>I receive the error:
>Runtime error '3024'
>Couldn't find file
>c:\vb40\projects\myproject\mydb.mdb
>Why does this still refer to the project directory, and NOT
>the directory from where it is being executed?
>Below is the code in question:
>  DBName = App.Path & "\" & "mydb.mdb"
>  Set MyWorkspace = Workspaces(0)
>  Set DBProfile = MyWorkspace.OpenDatabase(DBName, False, False)
>  Set MySet1 = DBProfile.OpenRecordset("profilestable")
>  MainForm.Data1.Refresh

Try this:

MainForm.Data1.DatabaseName = App.Path & "\mydb.mdb"
MainForm.Data1.Recordsource = "profilestable"

Regards

Ray



Wed, 24 Mar 1999 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. using application path (app.path)

2. App.Path only returning short path name - Why?

3. app.path only returns short path name

4. Help: App.Path returns 8.3 path in VB4/Win95

5. PATH-APP AND MDB-PATH

6. app-path and mdb-path

7. App.Path returns "short" path name

8. Changing Long Paths to Short Paths in a 16-bit App

9. SysCmd 603, "path","path"

10. Local path vs UNC Path

11. Setting the path to the path of the current application

12. Converting logical paths to UNC paths

 

 
Powered by phpBB® Forum Software