explicitly where they are just checkboxes you'll need something that identifies them, or you'll have to loop through all the controls and check to see if it's a check box.
You can do the following:
Name each of your checkboxes something like; chkbox1, chkbox2...
then
for i = 1 to n 'where n is the last checkbox
me.controls("chkbox" & i).value = true 'or whatever you want to do
next i
Additionally you can loop through all the controls on the form, but that would take longer, but - it would not need updated if you ever added more check boxes. You can find sample code of looping through controls by clicking on search and typing "Looking through controls"
Sprry, let me explain the problem. I have 2 columns of chckboxes on a continuous form. (So really I only have two is design view)
Check1, check2
I want that whenever check1 is checked, check2 should also be checked.
Private Sub Check1_Click()
If Me.Check1 = True Then Me.Check2 = True
If Me.Check1 = False Then Me.Check2 = False
end sub
However this code only works when the first checkbox in the column is checked and not for all the continuous boxes. I thought maybe if I'd loop through all of them and check which are checked and then check off the corresponding box. I don't know...
But how do I know which record they are up to? I am really confused with these continuous forms. When they check the first checkbox I want to check off the corresponding one but how do I know which checkbox they marked off? How do I know if it is the first, second or twenty-third? How do I refer to a specific row in a continuous form?
This is actually the first time I am dealing with a continuous form.
Are Check1 and Check2 bound ?
If yes you can try this:
[tt]Me.Check2 = Me.Check1[/tt]
in the Check1_AfterUpdate event procedure and perhaps in the form's Current event procedure too.
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
That worked, thanks so much. But I still have one problem with it.
My subform has several columns. The first is a checkbox the second is a client the third is a contact and the fourth is a checkbox. The first checkbox corresponds to the client and the second to the contact. There can be several contacts within one client so I can have one client listed several times, one for each contact.
Now, when the user checks off a client, I want all the checkboxes for that same client checked off. This is no problem because it is bound so I simply requery. Now, when user checks off a client I want all the contacts within that client marked off. I thought it would be simple beacause since all the checkboxes for the client are marked off I thought I could just see what's checked and mark off all the corresponding ones. But that doesn't seem to work. Your code works only for the client that was checked. If there are more contacts for that client it will not be checked.
SELECT company.Com_Name,company.noemail, customers.NoEmail,customers.C_FName, customers.C_LName, customers.C_Email
FROM customers LEFT JOIN company ON customers.Company_ID = company.Company_ID WHERE (instr(c_email," & "'@'" & ")>0) AND (company.Company_ID IN (" & srch & "))"
order by company.com_name
I'm astonished this recordset is updatable ...
Anyway, in the AfterUpdate event procedure of the subform you may add code like this:
DoCmd.RunSQL "UPDATE customers SET NoEmail=" & Check1 & " WHERE Company_ID=" & [name of company_ID control]
DoEvents
Me.Refresh
Another way is to play with the Me.RecordsetClone object.
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
Here is a simple routine I use occationally when I want to update records (on screen without getting the recordset again) using a bound continuous form.
Sub UpdateFormRecords()
Dim Cnt
Cnt = 0
DoCmd.GoToControl "SampleText"
DoCmd.GoToRecord , , acFirst
Do
'Do something (like Me.FirstName="Brad")
Cnt = Cnt + 1
MsgBox "Updated Record # " & Cnt
On Error GoTo NoMoreRecords
DoCmd.GoToRecord , , acNext
Loop
Exit Sub
NoMoreRecords:
DoCmd.GoToRecord , , acFirst
MsgBox "Update complete."
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.