assign value to a check box in code

  • Thread starter Thread starter Ann
  • Start date Start date
A

Ann

Can I assign a value=true to a check box, when it is
already true instead of false?

I think I can,but when I do it, it gives error message:

you cannot assign value to this object.

Any suggestions would be appreciated
 
Can I assign a value=true to a check box, when it is
already true instead of false?

I think I can,but when I do it, it gives error message:

you cannot assign value to this object.

Please post your actual code. I suspect there's an error in your
syntax; setting a control to a value will not depend on the current
value of the control.
 
Yes, you can since Access doesn't care what the existing
value (True or False) is:

However, there are cases where you cannot assign value to
a Control such as:

* The AllowEdits Property of the Form is set to False / No.
* The RecordSource of the Form is a non-updateable Query.
* The Control is a Calculated Control or is bound to a
Calculated Field of the RecordSource of the Form.
* ...

HTH
Van T. Dinh
MVP (Access)
 
Thanks.
I checked
* The AllowEdits Property of the Form is set to False /
No. It's Yes.
*The RecordSource of the Form is a updateable Query.

*The Control is a not a Calculated Control, it's a check
box.

The only thing I suspect is : the control I'll assing a
value for is on another loaded form.

Here is my code:

Private Sub btnClose_Click()
On Error GoTo btnClose_Click_Err

Dim Answer%

' check to see if all of the donors are entered, if
so set flag on frmDisclosureFilingEntry
Answer = MsgBox("Are all major donors entered?", 36,
CnDb)
If Answer = 6 And Isloaded
("frmDisclosureFilingEntry") Then Forms
("frmDisclosureFilingEntry")!DonorsIn = True

DoCmd.Close A_FORM, "frmDonorEntry"
If Isloaded("frmViewSchedules") Then Forms
("frmViewSchedules").SetFocus

btnClose_Click_Exit:
Exit Sub
btnClose_Click_Err:
MsgBox "Error: " + Error$, 0, "btnClose_Click"
Resume btnClose_Click_Exit
End Sub


When I use debug, it stopped at line:

Then Forms("frmDisclosureFilingEntry")!DonorsIn = True

Error message: you cannot assign value to this object.


Thanks in advance for any suggestions

Ann
 
Thanks.
I checked
* The AllowEdits Property of the Form is set to False /
No. It's Yes.
*The RecordSource of the Form is a updateable Query.

*The Control is a not a Calculated Control, it's a check
box.

The question concerned, not the Control, but the Form's recordsource
itself. What is the Recordsource property of the form that you're
trying to update? Is the form updateable if you do it manually?
The only thing I suspect is : the control I'll assing a
value for is on another loaded form.

Here is my code:
Then Forms("frmDisclosureFilingEntry")!DonorsIn = True

Try an unmixed syntax:

Forms!frmDisclosureFilingEntry!DonorsIn = True

or

Forms("frmDisclosureFilingEntry").Controls("DonorsIn") = True
 
Back
Top