Runtime error: could not find file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shahiryasin
    New Member
    • Oct 2011
    • 1

    #1

    Runtime error: could not find file

    okay, so i am designing a login system which is connected to a preset database i made in ms access. here's the code that i have written:

    Code:
    Private Sub cmd_ok_Click()
        
        'Declare variables
        Dim db As DAO.Database
        '= DBEngine.OpenDatabase(DbFile, False, False)
        Dim rs As Recordset
        Dim WS As Workspace
        
        'Set workspace,database and recordset
        Set WS = DBEngine.Workspaces(0)
            DbFile = App.Path & ("\sample database 2000.mdb")
        Set db = DBEngine.OpenDatabase(DbFile, False, False)
        Set rs = db.OpenRecordset("Login", dbOpenTable)
        
        'To compare data in textboxes with that in database
        If txt_password.Text = rs("Password") And txt_IDnum = rs("ID Number") Then
            
            'Show main menu form
            frm_mainmenu.Show
            Unload Me
            
        Else
            'Display message box
            MsgBox "Wrong Username and/or Password!", vbCritical, "Warning"
            
        End If
        
    End Sub

    there is a run time error which says that it could not find the file of my database. when debug, the line:

    Set db = DBEngine.OpenDa tabase(DbFile, False, False)

    seems to be the problem. what should i do?
    Last edited by Niheel; Oct 2 '11, 09:27 PM. Reason: code
Working...