Solved

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

Posted on 2002-05-04
4
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

615 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