Changing Form check boxes on open

G

Guest

Based on the following query :

SELECT Tasks.TaskID, Tasks.TaskDescription, Tasks.TimeSeconds,
Tasks.TaskType, Tasks.Frequency, Tasks.Duration, Tasks.StaffDependant,
Tasks.InmateDependant, Tasks.StaffOneOccuranceDaily, Tasks.OccursInFactory
FROM Tasks
WHERE (((Tasks.StaffDependant)=No) AND ((Tasks.StaffOneOccuranceDaily)=Yes));


A form was created. In that form is a True/False check box called
chkOccursInFactory.

When the form opens (the On Open Event Procedure is Me.chkOccursInFactory =
False) I get a error message " Run-time error '-2147352567 (80020009) You
can't assign a value to this object"

I am not sure why and I don't think it is because the field is not updatable
as I can update it with a mouse click. Not being able to change a check box
from true to false does not make sense to me. What would prevent this?

Thanks,

Dennis
 
G

Guest

The Open event is too soon for the form to know the control is there. If you
want it unchecked when the form opens, why not set it's default value to
False? That will do exactly the same thing.
If you need to address a control when you open a form, use the Load event.
 
G

Guest

I did as you suggested and I figured out that indeed the box was cleared. In
fact it looks like it was working the way it should have from the beginning.
It is my misconception that all of the records in the continous form would
change not just the one record (the first record) in the query list. I do not
know if it is possible but what I want is for all of the check boxes in the
returned select query to be unchecked when the form opens or even a button on
the form to uncheck all of the fields' returned records. I have spent about
two days tring to figure this out. I believe I will remember this lesson;)

How can I get all of the records in the select query to have a False value?
 
G

Guest

I don't know how you are going to do it with a query as your record source.
I have a similar situation, but I use a temp table to load in the records I
want, then i can manipulate them however I want to, then when the sub form
closes, I update the production table with what is in my temp table. Here is
the code I use to turn the check boxes on and off. Hope this helps:

Private Sub cmdSelectAll_Click()
'Updates all rows in the sub form AddToTable field
'Depending on the current setting
If Me.cmdSelectAll.Caption = "Select All" Then
CurrentDb.Execute ("UPDATE tblNewMasters SET
tblNewMasters.AddToTable = True;")
Me.cmdSelectAll.Caption = "DeSelect"
Me.cmdAddNew.Enabled = True
Else
CurrentDb.Execute ("UPDATE tblNewMasters SET
tblNewMasters.AddToTable = False;")
Me.cmdSelectAll.Caption = "Select All"
Me.cmdAddNew.Enabled = False
End If
Me.frmNewMActivity.Requery
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top