S
steamngn via AccessMonster.com
Good Morning All,
I have a form that contains an unbound multiselect listbox and a subform.
When a user selects a record in the subform, I open a recordset that I wish
to compare to the listbox records and then select each record that matches.
Here is my non-working code:
Private Sub btnSelComp_Click()
On Error GoTo Err_btnSelComp_Click
Dim rs As Recordset, strWhere As String, i As Long
Me.Text20.Value = Me.ID
Parent!LstEnteredDivs.Enabled = True
Set rstUnfiltered = CurrentDb.OpenRecordset("EventDivisionMaster",
dbOpenDynaset, dbReadOnly)
rstUnfiltered.Filter = "[CompetitorID] = " & Me.ID & " And [EventID] = " &
Parent!txtEventId
Set rs = rstUnfiltered.OpenRecordset
'Check to see if any records are returned
If Not rs.BOF And Not rs.EOF Then
'Wait for the recordset to completely load
rs.MoveLast
i = rs.AbsolutePosition
'Just check to see if there are records for now
MsgBox rs.RecordCount
End If
Dim lngList As Long
With Parent!LstEnteredDivs
For lngList = 0 To .ListCount - 1
If .ItemData(lngList) = [DivisionID] Then
.selected(lngList) = True
.Value = .ItemData(lngList)
Exit For
End If
Next lngList
End With
Set rs = Nothing
Exit_btnSelComp_Click:
Exit Sub
Err_btnSelComp_Click:
MsgBox Err.Description
Resume Exit_btnSelComp_Click
End Sub
The recordset is returning records, but I cannot seem to get the rest of it
to work. can someone see the errors in my ways?
I have a form that contains an unbound multiselect listbox and a subform.
When a user selects a record in the subform, I open a recordset that I wish
to compare to the listbox records and then select each record that matches.
Here is my non-working code:
Private Sub btnSelComp_Click()
On Error GoTo Err_btnSelComp_Click
Dim rs As Recordset, strWhere As String, i As Long
Me.Text20.Value = Me.ID
Parent!LstEnteredDivs.Enabled = True
Set rstUnfiltered = CurrentDb.OpenRecordset("EventDivisionMaster",
dbOpenDynaset, dbReadOnly)
rstUnfiltered.Filter = "[CompetitorID] = " & Me.ID & " And [EventID] = " &
Parent!txtEventId
Set rs = rstUnfiltered.OpenRecordset
'Check to see if any records are returned
If Not rs.BOF And Not rs.EOF Then
'Wait for the recordset to completely load
rs.MoveLast
i = rs.AbsolutePosition
'Just check to see if there are records for now
MsgBox rs.RecordCount
End If
Dim lngList As Long
With Parent!LstEnteredDivs
For lngList = 0 To .ListCount - 1
If .ItemData(lngList) = [DivisionID] Then
.selected(lngList) = True
.Value = .ItemData(lngList)
Exit For
End If
Next lngList
End With
Set rs = Nothing
Exit_btnSelComp_Click:
Exit Sub
Err_btnSelComp_Click:
MsgBox Err.Description
Resume Exit_btnSelComp_Click
End Sub
The recordset is returning records, but I cannot seem to get the rest of it
to work. can someone see the errors in my ways?