Adding checkbox records to an Access DB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jskarren
    New Member
    • Apr 2010
    • 1

    Adding checkbox records to an Access DB

    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:

    Code:
    If IsNull(DLookup("superuser", "needs", "superuser= " & Me.chksuperuser)) Then
        If Me.chksuperuser = True Then
          'add a record here
            rs.AddNew
            rs!unid = Me.unid
            rs!SuperUser = Me.chksuperuser
            rs.update
        End If
    Else
        MsgBox "Superuser Record Exist, unselect it and click update again"
    End If
    
    If IsNull(DLookup("attended", "needs", "attended= " & Me.chkattended)) Then
        If Me.chkattended = True Then
          'add a record here
            rs.AddNew
            rs!unid = Me.unid
            rs!attended = Me.chkattended
            rs.update
        End If
    Else
        MsgBox "Attended Fair Record Exist, unselect it and click update again"
    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
Working...