PC Review


Reply
Thread Tools Rate Thread

cannot delete record using db.execute

 
 
Nick Mleczko
Guest
Posts: n/a
 
      5th Feb 2008
Hi,

I'm trying to delete a record programatically, this is the code;

Dim db As DAO.Database
'Dim QD As QueryDef
'Dim where As Variant
Dim strSQL As String

Set db = CurrentDb()

Set db = CurrentDb

strSQL = "DELETE * FROM tblQuoteDescription where QuoteID =" &
intQuote & " and CustomerID =" & Forms!frmMain.CustomerID & ";"
db.Execute strSQL

db.Execute strSQL, dbFailOnError

Debug.Print db.RecordsAffected
Debug.Print strSQL

The records exists but the rowsaffected is returned as 0
the SQL statement is as follows;
DELETE * FROM tblQuoteDescription where QuoteID = 40100 and CustomerID
= 9;

ANy help would be greatly appreciated

N
 
Reply With Quote
 
 
 
 
Ken Snell \(MVP\)
Guest
Posts: n/a
 
      5th Feb 2008
What error are you getting when you run the code?

--

Ken Snell
<MS ACCESS MVP>


"Nick Mleczko" <(E-Mail Removed)> wrote in message
news:49b75bac-a806-4348-854d-(E-Mail Removed)...
> Hi,
>
> I'm trying to delete a record programatically, this is the code;
>
> Dim db As DAO.Database
> 'Dim QD As QueryDef
> 'Dim where As Variant
> Dim strSQL As String
>
> Set db = CurrentDb()
>
> Set db = CurrentDb
>
> strSQL = "DELETE * FROM tblQuoteDescription where QuoteID =" &
> intQuote & " and CustomerID =" & Forms!frmMain.CustomerID & ";"
> db.Execute strSQL
>
> db.Execute strSQL, dbFailOnError
>
> Debug.Print db.RecordsAffected
> Debug.Print strSQL
>
> The records exists but the rowsaffected is returned as 0
> the SQL statement is as follows;
> DELETE * FROM tblQuoteDescription where QuoteID = 40100 and CustomerID
> = 9;
>
> ANy help would be greatly appreciated
>
> N



 
Reply With Quote
 
 
 
 
Nick Mleczko
Guest
Posts: n/a
 
      6th Feb 2008
Ken,

As far as I know there was no error

I got around it by using the standard delete record macro that you can
generate from the button wizard, however I've noticed that you cannot
reuse the primary key again. Once used and deleted it will not be
reused... pity...

N
 
Reply With Quote
 
Ken Snell \(MVP\)
Guest
Posts: n/a
 
      9th Feb 2008
I assume that you're using an Autonumber field as the primary key? Once a
value is "assigned" to a record (even if the record is deleted before it's
saved), that value is gone and cannot be used again.

--

Ken Snell
<MS ACCESS MVP>


"Nick Mleczko" <(E-Mail Removed)> wrote in message
news:89da6a3d-fe2c-4a6c-bb53-(E-Mail Removed)...
> Ken,
>
> As far as I know there was no error
>
> I got around it by using the standard delete record macro that you can
> generate from the button wizard, however I've noticed that you cannot
> reuse the primary key again. Once used and deleted it will not be
> reused... pity...
>
> N



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete record using SQL but shows deleted record only. Jenny Microsoft Access 2 1st Feb 2007 01:01 AM
Cannot save record. Jet database engine cannot find a record =?Utf-8?B?SmFtZXMxOTU0?= Microsoft Access 0 12th Sep 2006 01:35 AM
Upon delete record, conditional delete record from another table =?Utf-8?B?UmljaDEyMzQ=?= Microsoft Access 6 14th Oct 2005 02:48 PM
Re: My server is tagged by someone, I cannot delete the folder they open, some are no name folder and some cannot delete, what should i do? Lanwench [MVP - Exchange] Microsoft Windows 2000 Networking 8 17th Jul 2003 08:14 PM
My server is tagged by someone, I cannot delete the folder they open, some are no name folder and some cannot delete, what should i do? hkjamjam Microsoft Windows 2000 Security 1 15th Jul 2003 08:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:25 AM.