Update query

D

Daniel P

I would like an event that when triggered will change the values of a column in my table to all true or all false (toggle). This event will be controlled by a check box.

Tim Ferguson gave give some code that works but generates an error message when the event is triggered a second time
Here's what I hav

****************code starts her
Private Sub Check8_Click(

If Me.Check8 = True The
a = Tru
Els
a = Fals
End I

strSQL = "UPDATE [tbl_Risk Assessment]" & vbNewLine & "SET [Include In Report]=" & a & ";
CurrentDb.Execute strSQL, dbFailOnErro

Me.List2.Requery 'Refreshes the info contained in the list bo
Ens su
*************Code end her

The problem I'm having is that it works find the first time I select the check box but if I choose, for whatever reason, to select it a second time an error/warning message pop up stating: "The data has been changed. Another user edited this record and saved the changes before you attemped to save your changes. Re-edit the record." (VBOKOnly

How do I get around this? I would like the user, should they choose, to be able to keep selecting the chceck box without generating any error messages. From what I get from the message, I need to save the table after modifying it the first time. How can I do that? I am unfamiliar with the

Thank you

Daniel
 
J

JeffW

Don't know if it'll resolve your issue, but have you tried moving your code
to the after update event of the check box?

Jeff

Daniel P said:
I would like an event that when triggered will change the values of a
column in my table to all true or all false (toggle). This event will be
controlled by a check box.
Tim Ferguson gave give some code that works but generates an error message
when the event is triggered a second time.
Here's what I have

****************code starts here
Private Sub Check8_Click()

If Me.Check8 = True Then
a = True
Else
a = False
End If

strSQL = "UPDATE [tbl_Risk Assessment]" & vbNewLine & "SET [Include In Report]=" & a & ";"
CurrentDb.Execute strSQL, dbFailOnError

Me.List2.Requery 'Refreshes the info contained in the list box
Ens sub
*************Code end here
 
A

Alex Dybenko

probably your form bound to the same table tbl_Risk Assessment, in this case
you have to either refresh form recordsourse each time you update tbl_Risk
Assessment, or add check box, bound to [Include In Report] on your form and
change it value, in form beforeupdate event

--
Alex Dybenko (MVP)
http://Alex.Dybenko.com


Daniel P said:
I would like an event that when triggered will change the values of a
column in my table to all true or all false (toggle). This event will be
controlled by a check box.
Tim Ferguson gave give some code that works but generates an error message
when the event is triggered a second time.
Here's what I have

****************code starts here
Private Sub Check8_Click()

If Me.Check8 = True Then
a = True
Else
a = False
End If

strSQL = "UPDATE [tbl_Risk Assessment]" & vbNewLine & "SET [Include In Report]=" & a & ";"
CurrentDb.Execute strSQL, dbFailOnError

Me.List2.Requery 'Refreshes the info contained in the list box
Ens sub
*************Code end here

The problem I'm having is that it works find the first time I select the
check box but if I choose, for whatever reason, to select it a second time
an error/warning message pop up stating: "The data has been changed.
Another user edited this record and saved the changes before you attemped to
save your changes. Re-edit the record." (VBOKOnly)
How do I get around this? I would like the user, should they choose, to
be able to keep selecting the chceck box without generating any error
messages. From what I get from the message, I need to save the table after
modifying it the first time. How can I do that? I am unfamiliar with the
 
T

Tim Ferguson

Tim Ferguson gave give some code that works but generates an error
message when the event is triggered a second time.

And I've responded in the original thread...


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top