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

Adding checkbox records to an Access DB

P: 1
All

I am new to using MS Access 2007 and to VB so please forgive me if all of this does not make sense. I have been working on a form that adds data to a tblNeeds table. There are 5 checkboxes called chksuperuser, chkattended, chkepicare, chkreportlead, and chkmgrattended on this form, I needed a way to check to see if a record existed before a new one was added, in researching this I found and modified the following code:

Expand|Select|Wrap|Line Numbers
  1. If IsNull(DLookup("superuser", "needs", "superuser= " & Me.chksuperuser)) Then
  2.     If Me.chksuperuser = True Then
  3.       'add a record here
  4.         rs.AddNew
  5.         rs!unid = Me.unid
  6.         rs!SuperUser = Me.chksuperuser
  7.         rs.update
  8.     End If
  9. Else
  10.     MsgBox "Superuser Record Exist, unselect it and click update again"
  11. End If
  12.  
  13. If IsNull(DLookup("attended", "needs", "attended= " & Me.chkattended)) Then
  14.     If Me.chkattended = True Then
  15.       'add a record here
  16.         rs.AddNew
  17.         rs!unid = Me.unid
  18.         rs!attended = Me.chkattended
  19.         rs.update
  20.     End If
  21. Else
  22.     MsgBox "Attended Fair Record Exist, unselect it and click update again"
  23. End If
This worked really well for the first checkbox, but adding the other checkboxes resulted in asyntax error and nothing is added. Is there a way to add code for all 5 checkboxes or what would the code look like to correctly check the 5 checkboxes for existing records and add records when ones do not exist. Any help on this would be appreciated.

Scott
Apr 20 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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