PC Review


Reply
Thread Tools Rate Thread

Delete is not happening

 
 
LAS
Guest
Posts: n/a
 
      19th Oct 2010
I have a function, listed below. When I run it, gs_sql is equal to this
(cut from the debugger's view immediate window):

"Delete from tblStudentTracking where student_id = 384 and incident_date =
#10/18/2010# and Incident_Sequence =3"

When I execute the function, no error is registered. But neither is the row
deleted. When I paste the same statement in a Delete query, it deletes the
row fine. What could be wrong?

TIA
LAS

Private Sub cmdDelete_Click()

On Error GoTo Delete_Err

gs_sql = "Delete from tblStudentTracking where student_id = " &
Me!Student_ID _
& " and incident_date = #" & Me!Incident_date _
& "# and Incident_Sequence =" & Me!Incident_Sequence

Call CurrentDb.Execute(gs_sql)

Delete_Exit:
Exit Sub

Delete_Err:
MsgBox Error$
Resume Delete_Exit
End Sub


 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      19th Oct 2010
On Mon, 18 Oct 2010 22:39:01 -0400, "LAS" <(E-Mail Removed)> wrote:

>I have a function, listed below. When I run it, gs_sql is equal to this
>(cut from the debugger's view immediate window):
>
>"Delete from tblStudentTracking where student_id = 384 and incident_date =
>#10/18/2010# and Incident_Sequence =3"
>
>When I execute the function, no error is registered. But neither is the row
>deleted. When I paste the same statement in a Delete query, it deletes the
>row fine. What could be wrong?
>
>TIA


You might be getting an error and not seeing it. Try using the dbFailOnError
argument to trap query errors:

Private Sub cmdDelete_Click()

On Error GoTo Delete_Err

gs_sql = "Delete from tblStudentTracking where student_id = " &
Me!Student_ID _
& " and incident_date = #" & Me!Incident_date _
& "# and Incident_Sequence =" & Me!Incident_Sequence

Call CurrentDb.Execute gs_sql, dbFailOnError

Delete_Exit:
Exit Sub

Delete_Err:
MsgBox Error$
Resume Delete_Exit
End Sub


This will transfer control to the Delete_Err code if there's any error in the
query.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
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
Re: It's happening again. Ken Blake, MVP Windows Vista General Discussion 0 15th Jul 2009 03:46 PM
Re: It's happening again. Richard Urban Windows Vista General Discussion 0 15th Jul 2009 02:01 PM
Delete cell shifts cells up - How to avaoid happening =?Utf-8?B?dXNlcjI2MTY=?= Microsoft Excel Misc 0 23rd Oct 2007 06:51 PM
Why is this happening... Bob Microsoft Access 5 11th Sep 2006 03:12 AM
shift delete for permanent results, happening with just delete =?Utf-8?B?YmxhY2tfcm9zZQ==?= Microsoft Outlook Discussion 0 20th Aug 2005 03:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:09 AM.