473,386 Members | 1,803 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,386 software developers and data experts.

Loop through Field names in code???

Mal
Hello.
I have inherited a badly designed database and am trying to improve
it.
It is basically a flat file for survey results.

one table holds, Name, Age etc as well as a field for each question.
I have created

tblResponders
Name etc

tblQuestions
IdNum
Question Text

tblResponses
IdNum
ResponderID
QuestionID
Response
I think the best way to clean things up now is to...
*loop through the Current Table
* Take one record at a time and then loop the fields
* build an append statement for each field matching the field name
to the question ID in the Question Table
* insert the Responder ID, Question ID and response to tblResponses

So... How do I do that looping....ie refer to the field names
I could even build a case statement.
eg.. Select Case <<SomeFieldName>>
Case "FirstImpression
MyQuestionID = 1
case "StaffFriendly"
MyQuestionID = 2
etc...

ideas? Thoughts?

TIA
Mal
Nov 13 '05 #1
1 12736
You can loop through the Fields collection of the TableDef.

Example:
http://members.iinet.net.au/~allenbrowne/func-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mal" <ma******@hotmail.com> wrote in message
news:75**************************@posting.google.c om...
Hello.
I have inherited a badly designed database and am trying to improve
it.
It is basically a flat file for survey results.

one table holds, Name, Age etc as well as a field for each question.
I have created

tblResponders
Name etc

tblQuestions
IdNum
Question Text

tblResponses
IdNum
ResponderID
QuestionID
Response
I think the best way to clean things up now is to...
*loop through the Current Table
* Take one record at a time and then loop the fields
* build an append statement for each field matching the field name
to the question ID in the Question Table
* insert the Responder ID, Question ID and response to tblResponses

So... How do I do that looping....ie refer to the field names
I could even build a case statement.
eg.. Select Case <<SomeFieldName>>
Case "FirstImpression
MyQuestionID = 1
case "StaffFriendly"
MyQuestionID = 2
etc...

ideas? Thoughts?

TIA
Mal

Nov 13 '05 #2

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

Similar topics

4
by: Michael Flanagan | last post by:
(Bottom line: I think what I'm looking for is an easy way of changing the case of key values in an array.) I've got code that I'm trying to make agnostic about the underlying database system I'm...
3
by: bitoulis | last post by:
Hi, is it possible to use the records of a table as the field names of another table? If yes, how is it done? Thanks in advance Laertes
2
by: dhnriverside | last post by:
Hi guys Ok, here's the situation. I'm building a reporting system for my application, that basically creates a CSV file based on a load of data in my database. I'm trying to make the...
3
by: Justin Clift | last post by:
Hi all, I'm creating a centralised table to keep a log of changes in other tables. In thinking about the PL/pgSQL trigger to write and attach to the monitored tables (probably a row level...
0
by: John Smith | last post by:
I'm using PDO for the first time. I want to get the field/column names from a SELECT query. I can get the names from the associative array returned by fetch(). But how do I get the field names if...
3
by: Billy | last post by:
I do a SELECT * from table command in an ASP page to build a text file out on our server, but the export is not to allow a field name rows of records. The first thing I get is a row with all the...
1
by: Billy | last post by:
I do a SELECT * from table command in an ASP page to build a text file out on our server, but the export is not to allow a field name rows of records. The first thing I get is a row with all the...
11
by: Tim Hunter | last post by:
Hi I am using WinXP and Access 2003 Is it possible to store the field names of a table in an array and then loop through the array and update the table using the field names stored in the array? I...
4
by: Bob | last post by:
Hi all, I've got a table that I've imported and it has junk at the top of the table, so after import I run a delete query to remove the junk lines then I'm left with the field names I want for...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.