By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,067 Members | 1,227 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,067 IT Pros & Developers. It's quick & easy.

Delete Statement

P: 28
Can you please check the following delete code? It doesn't delete data from table.
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2. Dim strID As Integer
  3.  
  4. strID = Me.SAIID.Value
  5.  
  6. 'strSQL = "DELETE * from tblCOSL WHERE tblCOSL.SAID = " & strID & ";"
  7. DoCmd.SetWarnings False
  8. DoCmd.RunSQL ("DELETE * from tblAGWL WHERE tblAGWL.SAID = " & strID & ";")
  9. DoCmd.RunSQL ("DELETE * from tblAGWM WHERE tblAGWM.SAID = " & strID & ";")
  10. DoCmd.RunSQL ("DELETE * from tblAGWH WHERE tblAGWH.SAID = " & strID & ";")
  11.  
Thank you.
Apr 17 '09 #1
Share this Question
Share on Google+
2 Replies


JustJim
Expert 100+
P: 407
@shimul
Possibly the double "I" in Me.SAIID.Value?

You would also need to put single quotes around strID since it is a string. You don't need the semi-colon (or the parentheses - I think)

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "DELETE * from tblAGWL WHERE tblAGWL.SAID = '" & strID & "'"
Also note that you really should pair up your SetWarnings False with a SetWarnings True.

Jim
Apr 17 '09 #2

NeoPa
Expert Mod 15k+
P: 31,709
It is always a good idea to ensure that variable name checking is enabled, AND your code compiles (at least compilation has been attempted), before submitting a question.

This avoids asking questions which are much more easily resolved on your own PC than on a forum.

To ensure variable name checking is enabled for all new modules, go to - Tools / Options / Editor (from the VBA Editor window) and set Require Variable Declaration to True (checked). For existing modules, ensure that the Option lines at the very top include :
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
To compile your project, select (again from the VBA Editor window) Debug / Compile Project Name.

We ARE generally happy to help with compilation problems too (If you find an error reported and you can't resolve it, let us know), but we do expect members to have tried compiling before submitting a question. That way we have a better idea of the sort of problem we're looking at.

I expect you wouldn't have needed to post the question if you'd done this first.
Apr 17 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.