I have a form with a tab control (each tab reprsenting a country) and two lists: Size and Colour.
When the user selects size and colour combinations, the selected size and colour list ids are populated to their respective temp tables.
The temp values are later recalled when the user clicks a Country tab: Size and Colour lists update to reflect data stored in the temp tables.
My problem is when there are no records in the temp tables, I get "No current record" errors. It is possible to have Country tabs without Size/Colour data.
But in order to reset the appearance of listSize or listColour, I have to perform a recordset count to establish how many times to loop thru the code.
It's a catch 22 to me. What am I missing? Maybe I'm just not seeing the wood for the trees...
Here's my code to repopulate the listSize control after the AU(stralia) tab is selected:
[blue]
Dim ctl1 as Control
Dim intRow as Integer, counter as Integer, searchID as Integer
...
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tbltmpSize WHERE [toTab] = 'AU' ORDER BY [recid];"
' count to establish recordset count - used in counter loop
rs.MoveLast
rs.MoveFirst
If rs.RecordCount > 0 Then ' do if records
' update listSize appearance with stored selections
Set ctl1 = me.listSize
For counter = 1 To rs.RecordCount
searchID = rs![recID]
For intRow = 0 To ctl1.listCount - 1
If ctl1.Column(0, intRow) = searchID Then
ctl1.Selected(intRow) = True
Exit For
End If
Next intRow
rs.MoveNext
Next counter
Else:
...
End If[/blue]
??!!
L.
When the user selects size and colour combinations, the selected size and colour list ids are populated to their respective temp tables.
The temp values are later recalled when the user clicks a Country tab: Size and Colour lists update to reflect data stored in the temp tables.
My problem is when there are no records in the temp tables, I get "No current record" errors. It is possible to have Country tabs without Size/Colour data.
But in order to reset the appearance of listSize or listColour, I have to perform a recordset count to establish how many times to loop thru the code.
It's a catch 22 to me. What am I missing? Maybe I'm just not seeing the wood for the trees...
Here's my code to repopulate the listSize control after the AU(stralia) tab is selected:
[blue]
Dim ctl1 as Control
Dim intRow as Integer, counter as Integer, searchID as Integer
...
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tbltmpSize WHERE [toTab] = 'AU' ORDER BY [recid];"
' count to establish recordset count - used in counter loop
rs.MoveLast
rs.MoveFirst
If rs.RecordCount > 0 Then ' do if records
' update listSize appearance with stored selections
Set ctl1 = me.listSize
For counter = 1 To rs.RecordCount
searchID = rs![recID]
For intRow = 0 To ctl1.listCount - 1
If ctl1.Column(0, intRow) = searchID Then
ctl1.Selected(intRow) = True
Exit For
End If
Next intRow
rs.MoveNext
Next counter
Else:
...
End If[/blue]
??!!
![[ponder] [ponder] [ponder]](/data/assets/smilies/ponder.gif)