wrkoutbeef
New Member
- Joined
- Jan 9, 2015
- Messages
- 1
Here is the code I have, I looking like it works, but it get suck in an endless loop of some kind, not from the do while. It looks like it is how I have set up the ListBox. Help
Set dbs = CurrentDb
Me.ListBoxVich.RowSource = " "
Me.ListBoxVich.ColumnCount = 6
Me.ListBoxVich.ColumnWidths = "500;1500;300;1700;500"
Set rst = dbs.OpenRecordset("Select [AutoSchedule].AutoYear, " & _
" [AutoSchedule].AutoMakeModel, " & _
" [AutoSchedule].AutoType, " & _
" [AutoSchedule].AutoVin," & _
" [AutoSchedule].CostNew " & _
"From [AutoSchedule] " & _
"Where [AutoSchedule].AutoDistNumb = " & SelectedDistNumber & "" & _
"And [AutoSchedule].AutoPlanYear = " & SelectedYear & ";")
If rst.EOF Then
Me.ScrMessage = "Unable to find an Auto Record"
Else
Do While Not rst.EOF
ListItem = rst.Fields(0) & " ; " & rst.Fields(1) & " ; " & rst.Fields(2) & " ; " & rst.Fields(3) & " ; " & rst.Fields(4)
Me.ListBoxVich.AddItem ListItem
Me.ScrMessage = ListItem
rst.MoveNext
Loop
End If
Set dbs = CurrentDb
Me.ListBoxVich.RowSource = " "
Me.ListBoxVich.ColumnCount = 6
Me.ListBoxVich.ColumnWidths = "500;1500;300;1700;500"
Set rst = dbs.OpenRecordset("Select [AutoSchedule].AutoYear, " & _
" [AutoSchedule].AutoMakeModel, " & _
" [AutoSchedule].AutoType, " & _
" [AutoSchedule].AutoVin," & _
" [AutoSchedule].CostNew " & _
"From [AutoSchedule] " & _
"Where [AutoSchedule].AutoDistNumb = " & SelectedDistNumber & "" & _
"And [AutoSchedule].AutoPlanYear = " & SelectedYear & ";")
If rst.EOF Then
Me.ScrMessage = "Unable to find an Auto Record"
Else
Do While Not rst.EOF
ListItem = rst.Fields(0) & " ; " & rst.Fields(1) & " ; " & rst.Fields(2) & " ; " & rst.Fields(3) & " ; " & rst.Fields(4)
Me.ListBoxVich.AddItem ListItem
Me.ScrMessage = ListItem
rst.MoveNext
Loop
End If