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

Adding and deleting records based on a checkbox

P: 2
Hi all,

I'm new to this so please be a little bit patient with me :-)

I have the following problem of which I thought i could solve it easily.... But I'm sad to say I can't find the solution. And I have been going at it for a few days now.....

I have a form with a few checkboxes and a table with fields ID=counter, buro=number and dienst=number.
When the box on the form is checked a record should be added to the table (for example buro=2 and dienst=5) and when the box is unchecked this record should be deleted.

Can someone please help me with this because I seem to be going around in circels....

I would be very thankfull for any help.....

Nov 8 '08 #1
Share this Question
Share on Google+
2 Replies

P: 25
please try the logic below:

Expand|Select|Wrap|Line Numbers
  1. If CheckBox.Value = 0 Then
  2.     str_sql = "Delete from table where field1 = " & buro & " and field2 = " & dienst
  3. Else
  4.     If CheckBox = -1 Then
  5.         str_sql = "Insert into table(field1, field2) values(" & buro & ", " & dienst & ")"
  6.     End If
  7. End If
  9. Docmd.RunSQL str_sql
Nov 11 '08 #2

P: 2
This works like a charm....
I am a happy person.
Thank you so much for your help.
Nov 12 '08 #3

Post your reply

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