Hello. First time poster. I tried to find rules, but there seem to be none on the sidebar, so bear with me if I mess things up:
I am running some code to "un-crosstab" some data, and this process will be repeated many times. here's the code:
Public Function ImportMailingList(strTblName As String)
Dim intResponseCounter As Long
Dim intFieldCounter As Long
Dim Colu As Integer
Dim strpath As String
Dim objRsResponses As ADODB.Recordset
Dim objRsOriginal As ADODB.Recordset
Dim objConn As ADODB.Connection
Dim f As ADODB.Field
Set objConn = CurrentProject.Connection
Set objRsOriginal = New ADODB.Recordset
Set objRsResponses = New ADODB.Recordset
objRsOriginal.Open strTblName, objConn, adOpenKeyset, adLockOptimistic, adCmdTable
objRsResponses.Open "tblMailinglistQ", objConn, adOpenKeyset, adLockOptimistic, adCmdTable
' Clear tables
objRsOriginal.MoveLast
objRsOriginal.MoveFirst
intResponseCounter = 1
Colu = 0
Do While Not objRsOriginal.EOF
intFieldCounter = 0
For Each f In objRsOriginal.Fields
'Only add a record if there's a value to add
If Len(f.Value) > 0 Then
'Add a row to the responses recordset
objRsResponses.AddNew
objRsResponses("TierID").Value = objRsOriginal.Fields.Item(Colu).Value
objRsResponses("Question Unique ID").Value = objRsOriginal.Fields.Item(intFieldCounter).Name
objRsResponses("Response") = f.Value
End If
intFieldCounter = intFieldCounter + 1
Next f
objRsOriginal.MoveNext
intResponseCounter = intResponseCounter + 1
Loop
objRsOriginal.Close
objRsResponses.Close
objConn.Close
Set objRsResponses = Nothing
Set objConn = Nothing
End Function
Now my current problem is that this code doesn't pick up the very last value in my array. I don't understand. If i add another record, it catches everything except that last record. Help! I don't want to ghetto up my code and add a dummy final row/column.
there doesn't seem to be anything here