Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

948 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

18 Experts available now in Live!

Get 1:1 Help Now