Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2005
    Posts
    11

    Unanswered: What I thought was a simple project...

    I have to make an Access form which serves as a questionnaire at a sales kiosk. Time and complexity are issues for the client, as they are for me since I'm no Access expert.

    This questionnaire will ask for the standard stuff - name, address, phone, etc.

    Then it asks for a lot of demographic info. Some of these are in drop-down lists, others are just checkboxes.

    For instance, a question might be: "What outdoor activities do you enjoy?", then there might be 20(!) checkboxes. Another might be: "What are the ages of the adults in your residence?". This would have a drop down box with the choices.

    Once the form is completed, the data is saved, a new unfilled form appears, and a copy is printed out. The printout is the most important use of the data at this time.

    One problem I've run into already is that Access forms handle checkboxes differently than I'm used to. I was hoping to simply have multiple checkboxes store different values in the same table field, i.e. if a person checks "Basketball" and "Tiddlywinks" and "Golf", then those would be stored in the "personalInterests" field, but I see that's not going to work.

    Pointers or guidance, anyone?

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    What does your table structure look like? It should be something like:

    tblCustomer
    CustID
    CustName
    CustAddress
    ...

    tblInterest
    InterestID
    IntersestDesc

    tblCustInterests
    CustID
    InterestID

    For each checkbox selected, you would add another record to the CustInterests table.
    Inspiration Through Fermentation

  3. #3
    Join Date
    Feb 2005
    Posts
    11
    That's what I was afraid of! OK, working on it now.

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by btwnc
    I have to make an Access form which serves as a questionnaire at a sales kiosk. Time and complexity are issues for the client, as they are for me since I'm no Access expert.

    One problem I've run into already is that Access forms handle checkboxes differently than I'm used to. I was hoping to simply have multiple checkboxes store different values in the same table field, i.e. if a person checks "Basketball" and "Tiddlywinks" and "Golf", then those would be stored in the "personalInterests" field, but I see that's not going to work.

    Pointers or guidance, anyone?
    Welcome to the real world kid ...
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Feb 2005
    Posts
    11
    Quote Originally Posted by RedNeckGeek

    For each checkbox selected, you would add another record to the CustInterests table.
    OK, I've set up the tables to match your example. I've got relationships set up between tblCustInterests and the other two tables for the ID numbers.

    How do I put checkboxes on the form that will actually add records to tblCustInterests?

  6. #6
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Based on your first post, it looks like your form is unbound - that is, the user has to press a "Save" button and some code puts the data in the tables.

    Just put a check box and a description for each interest on the form.

    When the user "saves" the data, check the status of each check box
    (-1 means it's selected), and use
    Docmd.Runsql "Insert into tblCustInterests..."
    Inspiration Through Fermentation

  7. #7
    Join Date
    Feb 2005
    Posts
    11
    I'm sure my terminology was wrong due to ignorance. There's no reason I know of that the form needs to be unbound. I just need a button to go to the next (new) record and print.

    You totally lost me with how to handle the checkboxes.

  8. #8
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Sorry, looks like your stuck with learning some VB.
    Put your checkboxes on the form, naming them with something
    like: chkBox1, chkBox2, ....

    There's several ways to accomplish this, here's the least complex IMO, although not necessarily the "right" way to do this.

    Each check box has an OnClick event. Click on the ellipses (...) next to the
    On Click property and select the Code Builder from the Wizard.

    In your vb window, You'll have to react to whether the check box was "checked" or "unchecked".

    Code:
    Private Sub chkBox1_Click()
       Dim strSql as string
        If chkBox1 then
          'the box is checked
          strSql = "Insert into tblCustInterests (custId, interestid) " _
              & "Values (" & Me.txtCustId & ", 1)
        Else
          'the check box was unchecked
          strSql = "Delete * from tblCustInterests " _
              & "Where CustID = " & Me.txtCustId & " and interestid = 1"
        End If
        Docmd.Runsql strSql
    End Sub
    For chkBox2 change all the "1"s in the above code to "2", and so on.

    *This code is untested, and you really should add some error checking.
    Inspiration Through Fermentation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •