Hi
So I am trying to populate a temporary table in the same form I created it. I create a temporary table based on a survey the user summited. I want to populate that table with questions. It would look like:
Municipality Question3 Question5 Question 19
Population? Date Created Personnel
Toronto 2 mil December 3 000
I am confused about how to access a table when the table is not where the form's data comes from. Should I create this in a macro? Is there a way to access a record from any table?
Here is my code to create my temporary table for the record.
*********************
Option Compare Database
Private Sub Command12_Click()
Dim sqlStr
Dim strWhere As String
Dim SurveySelect As Integer
Dim result
Dim count As Integer
SurveySelect = 3
Dim trackQuestionID(50) As Integer
count = 0
sqlStr = "CREATE TABLE tempTable ( "
sqlStr = sqlStr & "Municipality longtext, "
result = DLookup("QuestionID", "Question", "SurveyID = " & SurveySelect & strWhere)
Do While (Not IsNull(result))
trackQuestionID(count) = result
sqlStr = sqlStr & "Question" & result & " LONGTEXT, "
strWhere = strWhere & " and QuestionID <> " & result
count = count + 1
result = DLookup("QuestionID", "Question", "SurveyID = " & SurveySelect & strWhere)
Loop
sqlStr = Mid(sqlStr, 1, Len(sqlStr) - 2)
sqlStr = sqlStr & " );"
DoCmd.RunSQL sqlStr
End Sub
So I am trying to populate a temporary table in the same form I created it. I create a temporary table based on a survey the user summited. I want to populate that table with questions. It would look like:
Municipality Question3 Question5 Question 19
Population? Date Created Personnel
Toronto 2 mil December 3 000
I am confused about how to access a table when the table is not where the form's data comes from. Should I create this in a macro? Is there a way to access a record from any table?
Here is my code to create my temporary table for the record.
*********************
Option Compare Database
Private Sub Command12_Click()
Dim sqlStr
Dim strWhere As String
Dim SurveySelect As Integer
Dim result
Dim count As Integer
SurveySelect = 3
Dim trackQuestionID(50) As Integer
count = 0
sqlStr = "CREATE TABLE tempTable ( "
sqlStr = sqlStr & "Municipality longtext, "
result = DLookup("QuestionID", "Question", "SurveyID = " & SurveySelect & strWhere)
Do While (Not IsNull(result))
trackQuestionID(count) = result
sqlStr = sqlStr & "Question" & result & " LONGTEXT, "
strWhere = strWhere & " and QuestionID <> " & result
count = count + 1
result = DLookup("QuestionID", "Question", "SurveyID = " & SurveySelect & strWhere)
Loop
sqlStr = Mid(sqlStr, 1, Len(sqlStr) - 2)
sqlStr = sqlStr & " );"
DoCmd.RunSQL sqlStr
End Sub