DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: DB File Won't Open Again

  1. #1
    Join Date
    Sep 2004

    DB File Won't Open Again

    This code worked yesterday but it wouldn't won't work today on the first or second run attempt. I got the error message "File Not Found." I closed the project, opened it again and the third time it worked fine. Worked fine on the fourth attempt too. Am I losing it or is VB6 and Access on drugs? I use XP SP3 and Access 2003, SP3.

    Private Sub form_load()
    Dim sPath As String

    Open "MyDatabase.mdb" For Input As #1

    Set dbMyDB = OpenDatabase("MyDatabase.mdb")
    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

    End Sub

    Private Sub lstRecords_Click()

    rsMyRS.FindFirst "ID=" & Str(lstRecords.ItemData(lstRecords.ListIndex))
    txtPhone.Text = rsMyRS!Phone
    txtName.Text = rsMyRS!Name
    txtMoCost.Text = rsMyRS!MoCost
    txtKwh.Text = rsMyRS!kWh

    End Sub

  2. #2
    Join Date
    Nov 2003
    Alameda, CA
    First, why are you opening the file? There is not need to do it, just let sql doing its job. The lines of code
    Dim sPath As String
    Open "MyDatabase.mdb" For Input As #1
    are completely useless.
    Second, I suggest you to write the full path of the file, if you just use "MyDatabase.mdb" the program will work only when the working folder and the file path are the same.

    Please, use the [code] tag to post you code...
    "There are two ways to write error-free programs. Only the third one works."

Similar Threads

  1. Using Excel with
    By partyk1d24 in forum .NET
    Replies: 26
    Last Post: 03-28-2014, 01:49 AM
  2. Can't Open DB File
    By wisgro in forum VB Classic
    Replies: 4
    Last Post: 10-04-2010, 06:55 AM
  3. I ask library open file access 2000
    By dong in forum VB Classic
    Replies: 9
    Last Post: 12-03-2009, 12:58 PM
  4. Replies: 1
    Last Post: 04-17-2006, 01:20 AM
  5. How to open a bmp file?
    By FrankWu in forum Java
    Replies: 0
    Last Post: 08-16-2002, 04:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center