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
Re: Runtime error '13' Type mismach vb6
Where? I'm guessing rs("price")
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
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).
Re: Runtime error '13' Type mismach vb6
What line is throwing the error?
Re: Runtime error '13' Type mismach vb6
Quote:
Originally Posted by
GoA_TrancE
what about "price"?
Just trying to read your mind on where the error is :D