Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to list all values in table

Status
Not open for further replies.

ericchajmovic

Programmer
May 15, 2002
11
US
Hello,

I have a database that tracks responses of seminar attendees. I have a table of questions as follows:
Table: Questions
Field: QuestionID
Field: Type
Field: QuestionNum
Field: Question

I have an additional table:
Table: tblSurveys
Field: ServeyID
Field: TeacherID
Field: SessionID
Field: QuestionID
Field: Answer

I would like to put all the questions from the table tblQuestions onto a form, where the data entry clerk will be able to fill in the responses of the attendees. How can I enumerate through the table and dynamically place the questions on the form?

Any help would be appreciated!

Thanks,

Eric Chajmovic
 
Here, I have named the text boxes the same as a field on the question table. Then loop through all the labels, capture the label parent property name. Look up the question on the question table that matches the contol name and assign the value of that field to the label caption property. Also there are several forms, so I need the form parameter on the question table
I hope this will at least get you started.

Dim rs As New ADODB.Recordset, sSql As String, lbl As Control, sQ As String

On Error Resume Next
For Each lbl In frm
If TypeOf lbl Is Label Then

sQ = lbl.Parent.Name
sSql = "SELECT QuestionNo, QuestionTxt FROM tblQuestions " _
& "WHERE FrmName = '" & frm.Name & "' and QuestionNo = '" & sQ & "'"
rs.Open sSql, CurrentProject.Connection, adOpenStatic, adLockReadOnly, adCmdText
lbl.Caption = rs("QuestionTxt")
rs.Close
End If
Next lbl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top