Tabular Form w/ Check Box (1 Viewer)

gilescis

D. Castaldo
Local time
Today, 07:19
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:
 

SOS

Registered Lunatic
Local time
Today, 04:19
Joined
Aug 27, 2008
Messages
3,514
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
 

gilescis

D. Castaldo
Local time
Today, 07:19
Joined
Jan 23, 2006
Messages
106
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
 

missinglinq

AWF VIP
Local time
Today, 07:19
Joined
Jun 20, 2003
Messages
6,420
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:

SOS

Registered Lunatic
Local time
Today, 04:19
Joined
Aug 27, 2008
Messages
3,514
How about just an Update query instead of iterating through the recordset?
 

Friday

Registered User.
Local time
Today, 12:19
Joined
Apr 11, 2003
Messages
542
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
 

gilescis

D. Castaldo
Local time
Today, 07:19
Joined
Jan 23, 2006
Messages
106
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

Top Bottom