General discussion

Locked

Run Time Error '13' help !!!

By aplatfl ·
Everytime I delete a record from my DB using the following code i get this 'type mismatch ' error. I can`t seem to get it to work error free.

command1_click()
dim rs as adodb.recordset
rs.delete
rs.requery
loadvalues
'my connection is already declared in the gen decl
When i debug it goes to the loadvalues procedure's first textbox. When I move the cursor over the highlighted text box there seems to be empty data.
How can i fix this?
Thanks in advance..

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Run Time Error '13' help !!!

by M. Paradise In reply to Run Time Error '13' help ...

When calling RS.Delete, have you first performed a query? You may receive an error if the RS is not initialized with a query.

Collapse -

Run Time Error '13' help !!!

by aplatfl In reply to Run Time Error '13' help ...

Poster rated this answer

Collapse -

Run Time Error '13' help !!!

by ukothari In reply to Run Time Error '13' help ...

Hi,

From the code it looks like you have just declared the rs varaible. Unless you set this variable by executing a query or assigning another recordset object, it will be null and you can not perform other operations on it.

Hope this helps.
Regards...

Uday

Collapse -

Run Time Error '13' help !!!

by aplatfl In reply to Run Time Error '13' help ...

Poster rated this answer

Collapse -

Run Time Error '13' help !!!

Looks like you're trying to delete the current record that's on display on a form.
To do this you need to tell ADO which record you want to delete. The easiest procedure for this is not to create a recordset as you're trying to do but to pass an SQL delete statement to the connection.
For example (DAO-we haven't implemented ado yet)
on error goto woops
dim blnInTrans as boolean 'flag to tell you there's a transaction in progress
blnInTrans=false 'no trans to start withdim ws as workspace
dim db as database
set ws=dbengine(0)
set db=ws(0)
ws.begintrans
blnInTrans=true 'trans in progress
db.execute "delete * from <tablename here> t where t.<PrimaryKeyNameHere> = " & <primary key value youwant to delete here> & ";"
'if ther's no error the next line will execute
ws.committrans
blnInTrans=false
finish:
on error resume next
db.close
set db=nothing
set ws.close
set ws=nothing
exit function '(or exit sub)
woops:
if blnInTrans then 'check if ther's a trans in progress
ws.rollback
blnInTrans=false
end if
'handle your error here
'usual procedure is to fix what can be fixed
'or return a value from a function
resume finish

Things to note about the above:
As said this is based on ADO using Jet.
1. I think it's the Command object in ADO that does the work. something like <commandName>.execute "delete *....."
2. Transactions
If you're not using Jet then you may not have transactions available. Transactions enable you to avoid making changes if an error occurs. That's the committrans and rollback methods. I'm not sure what object in ADO handles this.
I know this isn't aperfect solution for you but maybe it will help.
John

Collapse -

Run Time Error '13' help !!!

by aplatfl In reply to Run Time Error '13' help ...

Poster rated this answer

Collapse -

Run Time Error '13' help !!!

by aplatfl In reply to Run Time Error '13' help ...

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums