lfarnsworth
Registered User.
- Local time
- Yesterday, 23:48
- Joined
- Jul 15, 2008
- Messages
- 25
Hello all,
I'm trying to write a bit of VBA code to check a check-box when a certain value to selected in a dropdown box. I've built it as an IF/THEN statement to run an SQL Update query. Here's the code:
It almost works... but when I select "2" from the dropdown list for a new record, it updates the Table1.yes/no value for every recond except the new one. Anyone have any tips on how to make it update all the records, including the new one?
Many thanks.
I'm trying to write a bit of VBA code to check a check-box when a certain value to selected in a dropdown box. I've built it as an IF/THEN statement to run an SQL Update query. Here's the code:
Code:
Private Sub text0_AfterUpdate()
On Error GoTo Err_text0_AfterUpdate
Dim frm As Form
Dim ctl As Control
Set frm = Forms!Form1
Set ctl = frm!Text0
'DoCmd.SetWarnings False
If ctl = "2" Then DoCmd.RunSQL "UPDATE Table1 SET Table1.[yes/no] = 'true' WHERE (((Table1.value)='2'))"
'DoCmd.SetWarnings True
Exit_text0_AfterUpdate:
Exit Sub
Err_text0_AfterUpdate:
MsgBox Err.Description
Resume Exit_text0_AfterUpdate
End Sub
It almost works... but when I select "2" from the dropdown list for a new record, it updates the Table1.yes/no value for every recond except the new one. Anyone have any tips on how to make it update all the records, including the new one?
Many thanks.