Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error when running  database.Execute(DELETE FROM ...) in DAO

Posted on 2002-05-04
4
Medium Priority
?
340 Views
Last Modified: 2008-02-01
I have a database that I need to delete records from.  The deletion is based on the customer number which is a dbLong and an dbAutoIncrField as well as an index field.  Here is the execution method I am using

mydb.Execute ("DELETE FROM [Clients] WHERE [Customer Number] = " & Chr(34) & custNum & Chr(34))

I can get it to work using the other fields like last name or first name but it specifically has to be done using the customer number.  The error I am getting is

Run-Time Error '3464':
Datatype mismatch in criteria expression.

The customer number is not blank and it is known. More points for extra effort.
0
Comment
Question by:groone
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 900 total points
ID: 6989745
take out the Chr(34)'s
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6989748
i mean:

mydb.Execute ("DELETE FROM [Clients] WHERE [Customer Number] = " & custNum)

the Chr(34)'s make it so you are comparing dbLong to string which is why you are getting the type mismatch
0
 
LVL 1

Expert Comment

by:baltman
ID: 6989880
I agree with bobbit31, that is also why your program is running fine when you use the first name or last name fields, since these are string values....

By the way, are the brackets [] required around the table name and the column name? I have never used them, without any problems...
Just checking.... I might learn something here!

BA
0
 
LVL 3

Author Comment

by:groone
ID: 6989907
Thanks...how stupid of me
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question