Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Select Checkbox take too long 1

Status
Not open for further replies.

WordTechinc

Programmer
Sep 4, 2009
38
I am try to update seleted check box but it takes so long to save into table. There are only 5,000 records in table.
Is there way to make this faster?


Here is code;

Sub SaveCurrentCheckBox()
Static blnSelect As Boolean
Set db = CurrentDb()
Set myrs = Me.RecordsetClone

With myrs
While Not .EOF
.Edit
If !NCselect = True Then
!NCselect = True
End If
If !NCselect = False Then
!NCselect = False
End If
.Update
.MoveNext
Wend
.Close
End With

myrs.MoveFirst
Me.Requery
End Sub
 
the way i read this you are juts setting the value in the table to what it is (not changing then )

what are you trying to do
 
I try to save check box value(selected or not selected) in the table. The table have 5,000 records only. This exec takes very long time.

 
I have continues forms and show all 5,000 records. I want to update the table where
check box select = -1
check box deSelectd = 0
 
Code:
 If !NCselect = True Then
   !NCselect = True
End If
If !NCselect = False Then
   !NCselect = False
End If
This doesn't change anything in the table.
You are setting the values to their current setting.


Randy
 
If you want to update (toggle the y/n) all the records in a table, it would be best to use an update query:
Code:
Dim strSQL as String
strSQL = "UPDATE [YourTableName] SET NCSelect = Not NcSelect"
CurrentDb.Execute strSQL, dbFailOnError


Duane
Hook'D on Access
MS Access MVP
 
If this is a bound form there is no need to update when you check/uncheck and move to the next record it is updated in the table
 
Thank you. I can use strSQL to update table. I also want to reset current value on the form too. I am using similar logic to "Select All" and "De Select All". Also Form check box name is NCselect and table check box field name is NCselect. I am attaching De Select logic. This also take a very long time.

Here is code;

Sub LoadDeSelectAll()

Static blnSelect As Boolean

Set db = CurrentDb()
Set myrs = Me.RecordsetClone

With myrs
While Not .EOF
.Edit
!NCselect = blnSelect
.Update
.MoveNext
Wend
.Close
End With
myrs.MoveFirst

Me.Refresh

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top