Here one Problem I've encountered, I've been told this was a bug.
Using check boxes and a table "Pick" field - Yes/no.
Using a cmdButton with ADO select all and Deselect choice.
When click select all, about 3 gets selected, then I hit the
select button again (mabey 2 times more)and all of them becomes selected. Here is the select all code:
Private Sub cmdSelAll_Click()
If Me.Filter = "" Then Me.Filter = "([Drawing Number] <> '')"
Me.FilterOn = True
Dim Cnx As ADODB.Connection 'Declares the Object Varibles
Dim Rst As ADODB.Recordset
Set Cnx = New ADODB.Connection
Set Rst = New ADODB.Recordset
Cnx.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Access.CurrentDb.Name & ";Persist Security Info=False"
If Cnx.State = 1 Then Cnx.Close
Cnx.Open
Rst.Open "select * from DrawingIndex_tbl where " & Me.Filter, Cnx, adOpenKeyset, adLockOptimistic
Do Until Rst.EOF
Rst.Fields("Pick") = True
Rst.Update
Rst.MoveNext
Loop
Rst.Close
Cnx.Close
Set Rst = Nothing
Set Cnx = Nothing
Me.Filter = Me.Filter
Me.Requery
Me.Refresh
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub
The select all code in DAO works fine, but the ADO code seems to do this.
Here is the DAO code for Select all:
Private Sub SelAll_frame_AfterUpdate()
Dim db As Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim int1 As Integer
Dim stat As Integer
Dim boPick As Boolean
'Set rst = Me.Recordset
If Len(Me.Filter) = 0 Then
MsgBox "Form must be filtered !!!"
Exit Sub
End If
strSQL = "SELECT DrawingIndex_tbl.* " _
& "FROM DrawingIndex_tbl " _
& "WHERE " & Me.Filter & ";"
Set db = DBEngine.Workspaces(0).Databases(0)
Set rst = db.OpenRecordset(strSQL, DB_OPEN_DYNASET)
With rst
If .RecordCount = 0 Then
Exit Sub
End If
If Me!SelAll_frame = 1 Then
boPick = True
Else
boPick = False
End If
.MoveFirst
Do Until .EOF
.Edit
!Pick = boPick
.Update
.MoveNext
Loop
.Close
End With
Set rst = Nothing
Set db = Nothing
Me.Requery
'rst.Close
'Set rst = Nothing
End Sub
So here is the question, What the cause and is there a fix for ADO?
Thanks
John Paul