[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Access Continous Form with check boxes

I have an Access continuous form.   In the header section I have a combo box that selects CompanyID’s  and displays all records in the continuous form with that CompanyID.  Is there a way in the detail section to have an check box, that when you check the check box on the first record, to have all the other records with that  CompanyId to show checked?
Any help would be appreciated!

Thank you.

0
ca1358
Asked:
ca1358
1 Solution
 
ComputronCommented:
One way is to use the click event of the checkbox to set a global variable. When the next record opens, check this global varible for its value and set the checkbox value in the new record accordingly.
0
 
ComputronCommented:
Actually, I may have misunderstood since its access.

Another may be to run an update query then refresh the continuous form to show all checked.
0
 
jjafferrCommented:
Hi ca1358,

The Checkboxs have to be Bound to a field in the Table, just like all the fields.

I prefer to have an UnBound checkbox in the Header, then when you check it, all the Checkboxes of all the Records of CompanyID to be checked,
Like Computron said, you need an update query like this:
UPDATE YourTableName SET YourCheckBoxName = -1 WHERE CompanyID=Forms![YourFormName]![CompanyID];
then you will have to Refresh the Form, OR Requery.

or you can have this line with db.CurrentExecute on click of the Checkbox
UPDATE YourTableName SET YourCheckBoxName = -1 WHERE CompanyID=me.CompanyID;

Beware, this code will NOT uncheck the Checkboxes if you changed your mind.

jaffer
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mbizupCommented:
So this check box would appear with every row on your continuous form, right?
Start by binding it to a field in the underlying table, if you haven't already.  Then add code to the After Update event of your checkbox to set the checkboxes for all the records in the form:

'This will set all the check boxes the same... If you check one they will all be checked.  If you uncheck one they will all be unchecked.
Private Sub YourCheckBoxName_AfterUpdate()
   Dim rs As Recordset
   Set rs = Me.RecordsetClone
   rs.MoveFirst
   Do Until rs.EOF
        rs.Edit
        rs!YourCheckBoxFieldName = Me.YourCheckBoxName
        rs.Update
        rs.MoveNext
       
   Loop
End Sub

'** Or do you want this...
'If the check box has been "Checked", all the others will be checked.  But if a check box has been unchecked, the others remain unchanged.
Private Sub YourCheckBoxName_AfterUpdate()
   if Me.YourCheckBoxName = TRUE then
        Dim rs As Recordset
        Set rs = Me.RecordsetClone
        rs.MoveFirst
        Do Until rs.EOF
             rs.Edit
             rs!YourCheckBoxFieldName = Me.YourCheckBoxName
             rs.Update
             rs.MoveNext      
        Loop
   end if
End Sub

0
 
ca1358Author Commented:
Thank you all for the help.  Sorry, for the late response but we have gone from having a tornado last week to a blizzard this week, that shut us down.
 I have to add a criteria to this, if the companyid in the header = to the companyid bound to the table then check [Positive Mark].

Private Sub Check36_AfterUpdate()
 Dim rs As Recordset
   Set rs = Me.RecordsetClone
     
   rs.MoveFirst
   Do Until rs.EOF
        rs.Edit
        rs![Positive Mark] = Me.Check36
        rs.Update
        rs.MoveNext
       
   Loop
End Sub

All you help is greatly appreciated.  


0
 
ca1358Author Commented:
also, tried this

Private Sub Check36_Click()
Dim sql As String
 

 sql = "update [roll exception report] set checkbox36 = -1 where [companyid] = me.[companyid]"
 CurrentDb.Execute sql, dbFailOnError
 
End Sub
0
 
ca1358Author Commented:

Private Sub Check36_Click()
Dim sql As String
 

 sql = "update [roll exception report] set checkbox36 = -1 where [company number] = " & Me.[Company Number]
 CurrentDb.Execute sql

   
   Me.Requery
   

End Sub
  I tried this and this didnt work.  
0
 
ca1358Author Commented:
I found another error in Syntax but still doent work.

Private Sub Check36_Click()
Dim sql As String
 

 sql = "update [roll exception report] set check36 = -1 where [companyid] = " & Me.[CompanyID]
 CurrentDb.Execute sql, dbFailOnError
 Me.Requery
   

End Sub
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now