Results 1 to 6 of 6

Thread: Runtime error '13' Type mismach vb6

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    57

    Unhappy Runtime error '13' Type mismach vb6

    Hello to all i have following code:

    Code:
    If txtName.Text = vbNullString Then
    MsgBox "You must fill the name box!", vbExclamation, "Warning"
    Exit Sub
    End If
    If txtName.Text = vbNullString Then
    MsgBox "You must fill the Name text box!", vbExclamation, "Warning"
    Exit Sub
    Else
    Dim db As Database
    Dim rs As Recordset
    Dim WS As Workspace
    Dim Max As Long
    
    Set WS = DBEngine.Workspaces(0)
        DbFile = (App.Path & "\DBS\DBXY.mdb")
        PwdString = "ss"
    Set db = DBEngine.OpenDatabase(DbFile, False, False, ";PWD=" & PwdString)
    Set rs = db.OpenRecordset("Items", dbOpenTable)
    If txtName.Text = rs.Index Then
    MsgBox "This contact already exists !", vbInformation, "Warning"
    Else
    rs.addNEW
    rs("name") = txtName.Text
    rs("price") = txtPrice.Text
    rs("kolichestvo") = txtKolichestvo.Text
    rs.Update
    Max = rs.RecordCount
    rs.MoveFirst
    
    frmMain.Combo1.Clear
    
    For i = 1 To Max
        Form1.Combo1.AddItem rs!FullName
      rs.MoveNext
    Next i
    Unload Me
    End If
    End If
    End Sub

    and when i try to run it i got
    Runtime error '13' Type mismach

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Runtime error '13' Type mismach vb6

    Where? I'm guessing rs("price")

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    57

    Re: Runtime error '13' Type mismach vb6

    what about "price"?
    and now i got
    Error : '91'
    Object variable or With Block not set

    Set rs = db.OpenRecordset("Items", dbOpenTable)
    here is the code
    Code:
    If txtName.Text = vbNullString Then
    MsgBox "You must fill the name box!", vbExclamation, "Warning"
    Exit Sub
    End If
    If txtName.Text = vbNullString Then
    MsgBox "You must fill the Name text box!", vbExclamation, "Warning"
    Exit Sub
    Else
    Dim db As Database
    Dim rs As Recordset
    Dim WS As Workspace
    Dim Max As Long
    
    Set WS = DBEngine.Workspaces(0)
        DbFile = (App.Path & "\DBS\DBXY.mdb")
       ' PwdString = "ss"
    'Set db = DBEngine.OpenDatabase(DbFile, False, False, ";PWD=" & PwdString)
    Set rs = db.OpenRecordset("Items", dbOpenTable)
    If txtName.Text = rs.Index Then
    MsgBox "This contact already exists !", vbInformation, "Warning"
    Else
    rs.addNEW
    rs("name") = txtName.Text
    rs("price") = txtPrice.Text
    rs("kolichestvo") = txtKolichestvo.Text
    rs.Update
    Max = rs.RecordCount
    rs.MoveFirst
    
    frmMain.Combo1.Clear
    
    For i = 1 To Max
        Form1.Combo1.AddItem rs!Name
      rs.MoveNext
    Next i
    Unload Me
    End If
    End If
    Last edited by GoA_TrancE; Apr 13th, 2010 at 01:01 PM.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Runtime error '13' Type mismach vb6

    That is because you have not Set the db variable before that point (see your first post for how to do it).

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Runtime error '13' Type mismach vb6

    What line is throwing the error?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Runtime error '13' Type mismach vb6

    Quote Originally Posted by GoA_TrancE View Post
    what about "price"?
    Just trying to read your mind on where the error is

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width