Hi,
I use the following code to add items to a report from a list box:
How can I modify the code so when the items get added to the test by item ID (TempID in the code) from the list box, they appear in the report in the same order that they were selected and not sorted in order of descending item ID?
Thank you
I use the following code to add items to a report from a list box:
Code:
Private Sub Command20_Click()
Dim rsTempTable As DAO.Recordset
Dim intLoop As Integer
Dim msg As Integer
msg = MsgBox("Do you want to save the current test for later use?", vbYesNo)
Select Case msg
Case vbYes
Text22.Value = 1
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "TestName"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Case Else
Set rsTempTable = CurrentDb.OpenRecordset("TempTest")
CurrentDb.Execute ("Delete * from TempTest Where TestID=0")
For intLoop = 0 To Form_TestMaker.List106.ListCount - 1
If Form_TestMaker.List106.Selected(intLoop) = True Then
rsTempTable.AddNew
rsTempTable!TempID = Form_TestMaker.List106.ItemData(intLoop)
rsTempTable!TestID = 0
rsTempTable.Update
End If
Next intLoop
Set rsTempTable = Nothing
DoCmd.OpenReport "Testing", acViewPreview, , "TestID=0"
DoCmd.OutputTo acReport, "Testing", acFormatRTF, "C:\Program Files\Test.rtf", True
DoCmd.Close acReport, "Testing"
DoCmd.Close acForm, "Test"
Form_TestMaker.Visible = True
End Select
End Sub
How can I modify the code so when the items get added to the test by item ID (TempID in the code) from the list box, they appear in the report in the same order that they were selected and not sorted in order of descending item ID?
Thank you