473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Checkbox Form

Rob
I have a lookup table of all the states "tblStates". Another table for
people "tblPeople". I need to create a form that tracks the states in
which people have lived. Therefore one person can have many states in
the residence table "tblHomes". Here is the catch. I need to create a
form that has checkboxes for all the states showing at the same time.
When the user checks off states in which the person has lived I want it
to add each of the checked states as a new record in tblHomes for that
person. Any ideas on how to accomplish this?

Aug 22 '06 #1
1 2527

Rob wrote:
I have a lookup table of all the states "tblStates". Another table for
people "tblPeople". I need to create a form that tracks the states in
which people have lived. Therefore one person can have many states in
the residence table "tblHomes". Here is the catch. I need to create a
form that has checkboxes for all the states showing at the same time.
When the user checks off states in which the person has lived I want it
to add each of the checked states as a new record in tblHomes for that
person. Any ideas on how to accomplish this?
okay, I actually tested this one...
I have a form, which is *not* bound to a table.
On it are
a textbox, "txtPersonID", which is formatted as a Fixed number, 0
decimal places.
a series of checkboxes for some states. (This is a test - I only made
4, but that's not really relevant.)
I changed the .Tag property of each checkbox to the 2-letter
abbreviation for the state it represented. (Sorry, that's going to be
tedious)
Then I added a button with this code attached:

Private Sub Command8_Click()

Dim rs As DAO.Recordset
Set rs = DBEngine(0)(0).OpenRecordset("tblHomes", dbOpenTable,
dbAppendOnly)

Dim ctl As Control

For Each ctl In Me.Controls
If TypeOf ctl Is CheckBox Then
If ctl = True Then
rs.AddNew
rs.Fields("PersonID") = Val(Me.txtPersonID)
rs.Fields("State") = ctl.Tag
rs.Update
End If
End If
Next ctl

rs.Close
Set rs = Nothing

End Sub

The only thing you should have to tweak is the PersonID part

Aug 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
2
by: Fred | last post by:
Hi, I defined a form consisting of checkboxes like: <form> <input type="checkbox" name=ck id=ck onclick="check(this.form)" <input type="checkbox" name=ck id=ck onclick="check(this.form)" ........
4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
4
by: Fabri | last post by:
How can I, on button click, to select ONLY the following 4 checkbox? I would like to do this without a for loop through form.lenght because this is only an example and I have to apply this script...
4
by: feanor | last post by:
I need to select children checkboxes when selecting the parent one. This is my function: function SelectChildrens(checkbox_name){ form = document.forms; Sname = checkbox_name.split("-"); for...
6
by: Dennis Allen | last post by:
Hi. I got a checkbox in a form. When the form is submitted, an email is generated. In the email text is the field name: on or off. The client doesn't want to see on or off, but yes or no. ...
1
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
4
by: Charlotte | last post by:
Hi, I have a problem with a ASP-script, can somewone help me ? here is what I've got: mypage.asp : .... code ... <%
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.