DB.Execute / strSQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I am having a problem getting the DB.Execute to work for
me. On my form I have 5 check boxes, that if checked=True
should envoke an action (update) query on the click event
of cmd button. What happens is the first query will run
but the rest will not (even if the chkd = True). I have
set break points on each of these statements to ensure the
values show up correctly, and they do (chkd=True). I have
even tried the DoCmdRunSQL and left SetWarnings turned on,
just to see if I get the prompts that it is going to
update X amount of records (and I do but then get no
results beyond the first of five queries).

Ex:
---
If chkCheckBox.Value = True Then
Db.Execute "sqlstatement"
End If

I have also tried:

Dim strSQL AS String

strSQL = "sqlstatement"
DB.Execute strSQL

Same results as I have listed above. Can anyone shed some
light on this?

Thank you in advance.

Todd Waldron
Austin, Tx.
 
Execute won't tell you if something went wrong unless you include the
dbFailOnError switch:
Db.Execute "sqlstatement", dbFailOnError

If you need an all-or-nothing result, you also need to use a transaction.
Example of how to use a transaction robustly:
http://allenbrowne.com/ser-37.html
 
Hi Allen,

Thank you for your response. I'll check out your site.

Thanks again,

Todd Waldron
Austin, Tx.
 
Back
Top