Solved

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now