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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is Checkall checkbox possible on an access form/subform 1

Status
Not open for further replies.

mrwendell

Programmer
Aug 22, 2003
43
US
Trying to put a checkbox or commandbutton on the parentform...and when either is activated will change the current state of all my checkboxes on a subform.datasheet to a true state! subform is the result of a query.

is this possible in access???
 
'in this example all check boxes have a sequential name...
'I.E. Check10, check11, check12...etc.
'the code toggles check values for the active form via a button click event.


Private Sub Command56_Click()
For intIndex = 10 To 16 Step 1
If Me.Controls("Check" & intIndex).Value = 0 Then
Me.Controls("Check" & intIndex).Value = 1
Else
Me.Controls("Check" & intIndex).Value = 0
End If
Next
End Sub
 
Thanks ETID, yes that code will work, but i fail to mention that checkboxes is a field in my table, record entered by my employees... so one, i wouldnt be able to name them individually,since they are generated when table is queried. i hope i am making sense. anyway, no way to tell access via commandbtn to check every boxes in this field and true when clicked?? and added note... cant use default true, because i use that step to indicate the record has been processed. trust me, if it was a matter of 10-20 checkboxes i wouldnt bother, as it is currently i am checking 100's boxes and desparately need to automate that.
 
'something like this in the click event of the button.
'substitute your table name in place of "my_table"
'and the checkbox field name in place of "target_field"


Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE my_table SET my_table.target_field = 1 WHERE (((my_table.target_field)<> 1)); ", -1
DoCmd.SetWarnings True

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub
 
GREAT!! thanks ETID...worked like a charm!! I hate to be greedy but since i am on a roll...:0)

now that i can automate the checkboxes...when i manually processed it i have a [udate] field populate with Now (current date) i can seem to get that code to work with my checkall command...under the docmd.runsql line i inserted if admin = true then udate = now ...nothing! got any idea?

i have tried that several different ways... i think it is not recognizing the checkbox [admin] as being true.
 
try looking for a checkbox value of 1(True) or 0(false)
... or even 0(true) -1(false) if that fails
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top