By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,934 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,934 IT Pros & Developers. It's quick & easy.

error 3464 Data type mismatch error!! ??

P: n/a
Does anyone know why I get the error 3464 Data type mismatch from the
following code.

I have a form with a combo(to choose a consumable) and 2 list boxes on
it.

list on left is all printers and list on right shows the ones
currently compatible with the consumable chosen in the combo at the
top.

I want to add printers to a corresponding compatible consumable type,
by clicking a button and it moving them from the left box to the right
and putting the two values in a link table as it is a many 2 many.

Now i can do this, but I also have a button which deletes the printers
from the consumable by selecting them in the right listbox.

here is the code that doesnt work (should remove items from link
table)...

****************************

Private Sub Command14_Click()

Dim frm As Form, ctl As Control
Dim varItm As Variant

Set frm = Forms![LinkTableFrm - Printers/Consumables]
Set ctl = frm![CompatiblePrinters]
For Each varItm In ctl.ItemsSelected
DoCmd.RunSQL _
"DELETE [LINKTBL-ConsumableToPrintertypes].PrinterID,
[LINKTBL-ConsumableToPrintertypes].consumable_id " & _
"FROM [LINKTBL-ConsumableToPrintertypes] " & _
"WHERE ([Consumable_ID]) = ('" & frm!ComboConsumableID & "') AND
([PrinterID]) = ('" & ctl.ItemData(varItm) & "' )"
Next varItm
Me!CompatiblePrinters.Requery

End Sub

**********

Why is it giving me type mismatch??

tia,

jon.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You should get in this habit ...

Dim strSQL As String, lngID as Long, strPrinter As String

lngID = frm!ComboConsumableID
strPrinter = ctl.ItemData(varItm)

strSQL = "DELETE FROM [LINKTBL-ConsumableToPrintertypes] " & _
"WHERE [Consumable_ID] = " & lngID & _
"AND [PrinterID] = '" & strPrinter & "';"

Debug.Print strSQL
DoCmd.RunSQL strSQL

Do you see how debugging is enhanced here? If ComboConsumableID
doesn't contain an number, the code will break on the first line above. By
printing the SQL to the debug window, you have a statement you can plunk
into the QBE to test (which will usually put the cursor on the offending char
or at least give you a more informative message.) Also, lose the Access
syntax for SQL. Dump all those parens and stop trying to delete from
columns, instead of tables. Yea, yea, I know-- it works. It works, but
it's wrong. DELETE sql should look like this ...

DELETE FROM [TableName] WHERE [Criteria]

This doesn't, however, answer your question, but it should help you figure
out where the problem is.
--
Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com/datafast
"Chicken Kebab Abdullah" <bo**********@yahoo.co.uk> wrote in message
news:db**************************@posting.google.c om...
Does anyone know why I get the error 3464 Data type mismatch from the
following code.

I have a form with a combo(to choose a consumable) and 2 list boxes on
it.

list on left is all printers and list on right shows the ones
currently compatible with the consumable chosen in the combo at the
top.

I want to add printers to a corresponding compatible consumable type,
by clicking a button and it moving them from the left box to the right
and putting the two values in a link table as it is a many 2 many.

Now i can do this, but I also have a button which deletes the printers
from the consumable by selecting them in the right listbox.

here is the code that doesnt work (should remove items from link
table)...

****************************

Private Sub Command14_Click()

Dim frm As Form, ctl As Control
Dim varItm As Variant

Set frm = Forms![LinkTableFrm - Printers/Consumables]
Set ctl = frm![CompatiblePrinters]
For Each varItm In ctl.ItemsSelected



Next varItm
Me!CompatiblePrinters.Requery

End Sub

**********

Why is it giving me type mismatch??

tia,

jon.

Nov 12 '05 #2

P: n/a
Thankyou, I will try that as soon as possible.

Im using a bad technique because I cut and pasted the code from
something similar I found on the newsgroup, changing it to fit my dbase.
I only just understand the basics and I dont really know what im doing.

I need to do a course in vb i think!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.