|
-
Apr 13th, 2010, 12:30 PM
#1
Thread Starter
Member
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
-
Apr 13th, 2010, 12:34 PM
#2
Re: Runtime error '13' Type mismach vb6
Where? I'm guessing rs("price")
-
Apr 13th, 2010, 12:57 PM
#3
Thread Starter
Member
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.
-
Apr 13th, 2010, 05:25 PM
#4
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).
-
Apr 14th, 2010, 01:17 AM
#5
Re: Runtime error '13' Type mismach vb6
What line is throwing the error?
-
Apr 14th, 2010, 04:09 AM
#6
Re: Runtime error '13' Type mismach vb6
 Originally Posted by GoA_TrancE
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|