ba******@yahoo.com (Barn Yard) wrote in message news:<e0**************************@posting.google. com>...
Pieter,
Thank you for replying and sorry about the lack of table structures.
I'll remember to put those in from now on. :) The FT1, FT2, and so on
are the question responses. I'm using append queries for each
question in order to arrive to tblResponses, I was looking for a
faster was to get there. I'm unsure how to use the recordset
property. Can you please show me a short example of how i might use
it? Thanks so much! -B
Here are the table structures:
----
tblFT (non-relational design)
ID Number
FT1 Text
FT2 Text
FT3 Text
FT4 Text
FT5 Text
FT6 Text
and so on....
-----
tblResponses' (normalized)
ID Number
QstnID Text
Respns Text
-----
So FT# is the question, and the response goes in that field. OK...
I think I need some amyl nitrate... LOL... so basically what you want
to do is loop through your denormalized table and grab the ID and FT#
(where # is some number corresponding to a field in the table), right?
If so, you could create your SQL statement using
tdf.fields(0).Name and tdf.fields(intCounter).Name Something like...
For intCounter = 1 to tdf.fields.count-1
strSQL = "INSERT INTO tblResponses(QstnID,Rspns) VALUES (SELECT
tblResponses.QstnID " & tdf.fields(intCounter).Name & " FROM
tblResponses)"
db.Execute strSQL, dbFailOnError
Next intCounter
Confused yet? Basically, the way I would go about it is to loop
through the fields collection of your denormalized table, and use a
CurrentDB.Execute strSQL kind of thing, where you build the SQL
statement on the fly. Have a look at the fields collection in help.
(A table consists of a zero-based collection of fields, so you can
refer to a field as tdf.fields(intFieldNo))
So then you can see automate most of this.
If this is all just way over your head, try something simple first to
get an idea of what's going on... something like
dim db as dao.database
dim tdf as dao.tabledef
dim fld as dao.field
set db=currentdb
set tdf = db.Tabledefs("tblFT")
for intCounter = 0 to tdf.fields.Count-1
debug.print intCounter, tdf.fields(intCounter).Name
next intCounter
set tdf=nothing
set db=nothing
you'll get something like this:
0 ID
1 FT1
2 FT2
3 FT3
....
then you can use that to build your SQL statement on the fly, and use
currentdb.Execute strSQL to execute the SQL statement for you.
Confused? Great! Mission accomplished. <g>