Tabular Form w/ Check Box

gilescis

D. Castaldo
Local time
Today, 16:32
Joined
Jan 23, 2006
Messages
106
I have a small form that has 3 fields from my employee tbl.
Field1-IsSelect ( yes/no) check box
Field2-lname
Field3-fname

I want the users to be able to put a check mark next to each emp name that they want to print the timesheet for. I can get that all to work, but now I need a button to clear those check marks(uncheck).

Any idea on how to do that.

Also is there any sample timeclock databases out there that i can get some ideas from on features,

Thanks
D.Castaldo
Skyland Fire Rescue:
 
Code to clear the checkboxes:

Code:
Dim ctl As Control
 
For Each ctl In Me.Controls
   If ctl.ControlType = acCheckBox Then
      ctl.Value = False
   End If
Next ctl
 
No that did not work unless im am missing a field name there.

the field name i want to clear is called IsSelected

I added a command button and placed your code in there but no go.

Any Ideas

Castaldo
Skyland Fire Rescue
 
SOS misread your post; his code unchecks all checkboxes on the current record only.

Try this:

Code:
Private Sub ClearCheckBoxes_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("YourTableName")
Do While Not rs.EOF
rs.Edit
rs!IsSelect = 0
rs.Update
rs.MoveNext
Loop

rs.Close
Set rs = Nothing
End Sub
Replace YourTableName with the actual name of your table.

Be sure Microsof DAO 3.6 Object Library is set in references (Tools - References)
 
Last edited:
How about just an Update query instead of iterating through the recordset?
 
with a tabular (continuous) form, you will probably need to work on the underlying data source, not the form. I assume you want to reset the value of a field (isSelect) to False/No from True/Yes. Something like this should work:

Code:
strSQL = "SELECT * FROM tbl1 WHERE isSelect=True"

Set qdef1 = CurrentDb.CreateQueryDef("", strSQL)
Set rs1 = qdef1.OpenRecordset(dbOpenDynaset)
With rs1
If Not .EOF Then
.MoveFirst
Do
.Edit
.Fields!isSelect = False
.Update
.MoveNext
Loop Until .EOF
End If
.Close
End With
Set rs1 = Nothing
qdef1.Close
Set qdef1 = Nothing
Me.Refresh
 
I dont understand what the heck im doing wrong. Neither of those options are working. Does anyone know of a sample working form that i can use to compare with mine.

thanks for all the help on this

Castaldo
Skyland Fire Rescue
 

Users who are viewing this thread

Back
Top Bottom