|
#1
|
|||
|
|||
|
VB6 Won't Open Access DB
Worked with a tutorial that is supposed to open a db file for input. No matter how I write the file path I get error messages .
The first attempt to open the file path that came with the tutorial generated the error message “Couldn’t find file.” The next two attempts are my doctoring. Attempt #2 generated error message “Unrecognized DB format.” Third attempt error message is, “File Not Found.” I use VB6, XP. 'Connect a database to a form Dim dbMyDB As Database Dim rsMyRS As Recordset Private Sub form_load() 'Open DB Attempts ' First attempt, Set dbMyDB = OpenDatabase("MyDatabase.mdb") ' Second attempt, Set dbMyDB = OpenDatabase("C:\VisualBasic\ConnectToDB\MyDatabase.mdb") ‘Third attempt, Open App.Path & "MyDatabase.mdb" For Input As #1 Set rsMyRS = dbMyDB.OpenRecordset("MyTable", dbOpenDynaset) If Not rsMyRS.EOF Then rsMyRS.MoveFirst Do While Not rsMyRS.EOF lstRecords.AddItem rsMyRS!Name lstRecords.ItemData(lstRecords.NewIndex) = rsMyRS!ID rsMyRS.MoveNext Loop End Sub Private Sub lstRecords_Click() rsMyRS.FindFirst "ID=" & Str(lstRecords.ItemData(lstRecords.ListIndex)) txtPhone.Text = rsMyRS!Phone End Sub |
|
#2
|
|||
|
|||
|
Second attempt is correct. Here's how to fix the "unrecognized database format" error: http://support.microsoft.com/kb/238401
__________________
Phil Weber http://www.philweber.com Please post questions to the forums, where others may benefit. I do not offer free assistance by e-mail. Thank you! |
|
#3
|
|||
|
|||
|
VB6 Won't Open Access DB
Thanks for responding so quickly Phil. Curious how I could set the path if I decide to share this with some colleagues no matter what folder they save it in. I thought App.Path was the way to go.
|
|
#4
|
|||
|
|||
|
The problem with App.Path is that non-administrators don't have write access to C:\Program Files. You should probably install the database to the user's AppData\Local folder and use the SHGetSpecialFolderLocation function to find it: http://hashvb.earlsoft.co.uk/Special_folders
__________________
Phil Weber http://www.philweber.com Please post questions to the forums, where others may benefit. I do not offer free assistance by e-mail. Thank you! |
|
#5
|
|||
|
|||
|
Interesting. A couple of years ago I wrote a small program that returns town names and zip codes when the user enters a telephone exchange. (The DB is a text file.) I used App.Path, shipped it to them and it works fine for them. Is that because I used a text file instead of access?
|
|
#6
|
|||
|
|||
|
No, it's probably because they're running as an Administrator on their PC. Unlike previous versions of Windows, Vista and Windows 7 do not make users Administrators by default.
__________________
Phil Weber http://www.philweber.com Please post questions to the forums, where others may benefit. I do not offer free assistance by e-mail. Thank you! |
|
#7
|
|||
|
|||
|
VB6 Won't Open Access DB
I see. The folks I sent the program to use XP and are likely designated administrators. Thanks Phil.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VB6 Connect to remote Access DB on server | vbxmax | VB Classic | 2 | 11-23-2005 02:21 AM |
| Spaces in filename when using OPEN random access | Mark | VB Classic | 0 | 01-31-2002 09:15 PM |
| Is access already open | Gregoire | VB Classic | 0 | 12-11-2001 07:27 AM |
| Access & SQL Server | David Jones | Database | 0 | 08-31-2001 01:22 PM |
| setting up multiuser env. using vb6 (DAO) & Access 97 | Jonathan Sullivan | VB Classic | 0 | 04-12-2001 06:39 AM |