Solved

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

Posted on 2002-05-04
4
331 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 225 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

831 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