I have a possibly silly question. I taught access to myself by using it so I might have spotty knowledge in certain areas. I have access 2003.
This is my code:
Basically I'm creating TMP_tblOut. After all of the entires have been added with the while loop I want to sort it by SortNum and save it. It seems that rstOut is sorted after .sort is run, but after the code runs TMP_tblOut is not sorted. Can somebody help me? Again, this might be an easy fix I'm overlooking and there might be silly mistakes in the code so I apologize in advance.
This is my code:
Code:
runSQL "SELECT DISTINCT TopicLabel, ContentLabel, First(Section) AS firstSection INTO TMP_tblLabels FROM TMP_tblMain GROUP BY TopicLabel, ContentLabel HAVING ContentLabel<>'__Heading__'"
Dim rstLabels As New ADODB.Recordset
rstLabels.Open "TMP_tblLabels", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
rstLabels.MoveFirst
strHeaders = "SortNum|" & IIf(labels, "Info|", "") & IIf(qnumcol, "Num|", "") & UCase(Join(strSurvey, "|"))
strFieldTypes = "Text" & IIf(labels, "|Text", "") & IIf(qnumcol, "|Text", "") & rep("|Memo", UBound(strSurvey) + 1)
createTable2 "TMP_tblOut", strHeaders, strFieldTypes
Dim rstOut As New ADODB.Recordset
rstOut.CursorLocation = adUseClient
rstOut.Open "TMP_tblOut", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rstLabels.EOF
rstOut.AddNew
rstOut!SortNum = sortQ(Join(strSurvey, "|"), rstLabels!FirstSection, rstLabels!TopicLabel, rstLabels!ContentLabel)
If labels Then rstOut!Info = formatInfo(rstLabels!TopicLabel, rstLabels!ContentLabel)
If qnumcol Then rstOut!Num = firstQNum(strSurvey(0), rstLabels!TopicLabel, rstLabels!ContentLabel)
For i = 0 To UBound(strSurvey)
rstOut(strSurvey(i)) = getQ(strSurvey(i), rstLabels!TopicLabel, rstLabels!ContentLabel, (i = 0 And qnumcol), prp, pri, pra, ltq, ro, nr, psi, psp)
Next
rstLabels.MoveNext
Wend
rstLabels.Close
rstOut.Sort = "SortNum"
rstOut.Save
rstOut.Close
Comment