-----Original Message-----
-----Original Message-----
Hello I have the following tables and I would like to have
an input form.
tblMain
RespondatID (Autonumber)
Gender (Text)
Qustion (Text)
Answer (Text)
tblGender
GenderID (AutoNumber)
Gender (Text) (Male and Female Entered as data)
tblQuestion
QuestionID (Autonumber)
Question (Text) (Q01,Q02... Q25 entered as data)
tblAnswer
AnswerID (Autonumber)
Answer (Text) (True and False entered as data)
How do I get an Input form so that I can have something
like the follwoing:
Are you male or Female (cbobox for the values of Male and
Female) selected value goes in tblMain as a record.
Q01 (CboBox with values of True or false) when selected
the Question Number goes in the relevant field in tblMain
(Question) and the answer given (true or False) goes in
the (Answer) field in tblMain.
How do I do this?
Hi, James.
Your current design has some problems that are easy to
fix. First, it's good that you've tried to normalize your
tables. Your foreign keys in tblMain, though, must match
in type to their "lookup" tables, i.e., tblMain->Gender,
Question, and Answer should all be numeric types to match
the AutoNumber primary keys of the lookup tables.
Also, try to name your tables based on the "thing" they
represent. If you find it difficult to do so, it could be
a clue that your table does not represent attributes of a
single thing, and therefore, not sufficiently normalized.
In your case, tblMain represents two things, Respondants
and Responses, which have a one-to-many relationship.
While there's no harm in keeping it, tblAnswer is also not
really required. You can always calculate a text value
from a Boolean in a form or report control, such as: =IIf
([Answer]=True, "True","False"). You could also work
around Gender if you wish.
I suggest the following table designs:
tblRespondants
==============
RespondantID AutoNumber
Gender Number (Foreign Key to tblGender)
tblResponses
============
ResponseID AutoNumber
RespondantID Number (Foreign Key to tblRespondants)
QuestionID Number (Foreign Key to tblQuestions)
Answer Yes/No
Keep tblGender and tblQuestion as you've defined them.
In the Relationships window, define the following
relationships:
One Side Many Side
================= =============
tblRespondants tblResponses
tblGender tblRespondants
tblQuestion tblResponses
For data entry, create a main form based on tblRespondants
and a continuous subform based on tblResponses, linked by
the RespondantID (i.e., set the subform control's
LinkMasterFields and LinkChildFields properties to
tblRespondants' primary key and tblResponses' foreign key,
respectively).
Use the combo box wizard to create combo boxes for all
fields for which you will store a foreign key and display
a value in the form, i.e., tblRespondants.Gender,
tblResponses.RespondantID, tblResponses.QuestionID,
tblResponses.Answer. Answer could alternatively be an
option group.
To turn the wizard on, display the Toolbox from form
design view, and toggle the Wizard button (a wand and
stars). For the combo boxes, tell the wizard to look up
its values from the appropriate lookup table, hide the
primary key, and store the selection in the appropriate
foreign key field. Access will store the numeric key, but
display the text of the second table field.
Your form will then display the Respondants' name and
gender, and all of the questions and answers associated
with him or her.
HTH
Kevin Sprinkel
.