Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > VB Classic

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-01-2009, 11:21 AM
wisgro wisgro is offline
Registered User
 
Join Date: Sep 2004
Posts: 34
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
Reply With Quote
  #2  
Old 11-01-2009, 11:37 AM
Phil Weber Phil Weber is offline
Super Moderator
 
Join Date: Nov 2003
Location: Portland, OR
Posts: 8,171
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!
Reply With Quote
  #3  
Old 11-01-2009, 11:45 AM
wisgro wisgro is offline
Registered User
 
Join Date: Sep 2004
Posts: 34
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.
Reply With Quote
  #4  
Old 11-01-2009, 11:55 AM
Phil Weber Phil Weber is offline
Super Moderator
 
Join Date: Nov 2003
Location: Portland, OR
Posts: 8,171
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!
Reply With Quote
  #5  
Old 11-01-2009, 12:00 PM
wisgro wisgro is offline
Registered User
 
Join Date: Sep 2004
Posts: 34
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?
Reply With Quote
  #6  
Old 11-01-2009, 12:28 PM
Phil Weber Phil Weber is offline
Super Moderator
 
Join Date: Nov 2003
Location: Portland, OR
Posts: 8,171
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!
Reply With Quote
  #7  
Old 11-01-2009, 12:45 PM
wisgro wisgro is offline
Registered User
 
Join Date: Sep 2004
Posts: 34
VB6 Won't Open Access DB

I see. The folks I sent the program to use XP and are likely designated administrators. Thanks Phil.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

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

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


All times are GMT -4. The time now is 01:13 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.