I have the following code in an Access 2000 Form:
Dim strsql As String, oldipa As String, itm As Variant
Dim rs As New ADODB.Recordset, rsgp As New ADODB.Recordset
strsql = "Select ipa from tbl_mailing_groups group by ipa"
If Not IsNull(Me.txtGroupid) Then oldipa = Me.txtGroupid
rs.Open strsql, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
Do Until rs.EOF
Me.txtGroupid = rs!ipa
Me.Combo10.Requery
strsql = "Select group from tbl_mailing_groups " & _
"Where ipa = """ & rs!ipa & """ Group By group"
rsgp.Open strsql, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
Do Until rsgp.EOF
'Clear groups
*** For Each itm In Me.Combo10
If Forms!frmJOMReports.Combo10.ItemData(itm) = rsgp!group Then
Forms!frmJOMReports.Combo10.ItemData(itm).Selected = True
End If
Next itm
rsgp.MoveNext
Loop
Call cmdPreviewScoreReport_Click
rs.MoveNext
Loop
The line above with the *** is giving me an error and nothing I've tried is correcting it. What I need to do is loop through all of the items in the combobox and if an item is in the Recordset the Selected property should be set to true. Any help would be appreciated.
Dim strsql As String, oldipa As String, itm As Variant
Dim rs As New ADODB.Recordset, rsgp As New ADODB.Recordset
strsql = "Select ipa from tbl_mailing_groups group by ipa"
If Not IsNull(Me.txtGroupid) Then oldipa = Me.txtGroupid
rs.Open strsql, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
Do Until rs.EOF
Me.txtGroupid = rs!ipa
Me.Combo10.Requery
strsql = "Select group from tbl_mailing_groups " & _
"Where ipa = """ & rs!ipa & """ Group By group"
rsgp.Open strsql, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
Do Until rsgp.EOF
'Clear groups
*** For Each itm In Me.Combo10
If Forms!frmJOMReports.Combo10.ItemData(itm) = rsgp!group Then
Forms!frmJOMReports.Combo10.ItemData(itm).Selected = True
End If
Next itm
rsgp.MoveNext
Loop
Call cmdPreviewScoreReport_Click
rs.MoveNext
Loop
The line above with the *** is giving me an error and nothing I've tried is correcting it. What I need to do is loop through all of the items in the combobox and if an item is in the Recordset the Selected property should be set to true. Any help would be appreciated.