Auto Check box

rhett7660

Still Learning....
Local time
Today, 13:59
Joined
Aug 25, 2005
Messages
371
Hi all..

I have two forms.

form number 1 is the main form (subform lists details based on a query)
form number 2 is the detail of the items in form #1

When I double click on a textbox it opens up the details of that item in form number 2.

In the detail form I have a check box that shows if the item is active or not. Checked = Active.

How do I have the check box automatically checked when I open the form? The only way it becames un-checked = not active is if the user un-checks it.

I have tried setting the default value to 0 and -1 but that didn't work.

Thanks
R~
 
Put some code on the form Open event to check the check box.


Me.CheckBoxname=-1
 
Or Me.CheckBoxName = True will do it too and that might be more explanatory to someone else who looks at it and doesn't know that -1 equals True. I usually like to use constants instead of literal values if possible for ease of reading (personal preference).
 
Ok I tried both methods but I am getting the following error message:

Run-time error - 2147352567 (80020009)
You can't assign a value to this object

I also have the following code when the form loads:

Code:
Private Sub Form_Load()
[Forms]![frmApplicantFullDetails].Requery
End Sub

and the following code when the form closes:

Code:
Private Sub Form_Close()
[Forms]![frmInvestigator]![sfrmApplicant].Requery
End Sub

R~
 
Last edited:
It sounds like the recordset is not updateable. Are you able to manually check the box. Is the recordsouce behind the form made up from several tables?
 
Keith..

Yes I can manually check the box and it will work. In fact if I don't check the box the new addition will not show in the subform because I only want to see active incidents in the subform. What I wanted to do is have the new entry be active no matter what until the incident is done and the active box is unchecked.

Here is the queries sql that the form is based off of:

Code:
SELECT tblApplicant.ApplicantID, tblApplicant.AppLName, tblApplicant.AppFName, tblApplicant.AppMInitial, tblApplicant.SocNumber, tblApplicant.Status, tblApplicant.Active, tblApplicant.ReasonForInactive, tblApplicant.EndResult, tblApplicant.EndResultMemo, tblApplicant.EndResultMemo, tblApplicant.FOSLName, [AppLName] & ", " & [AppFName] & " " & [AppMInitial] & "." AS AppName, tblApplicant.FOSRank
FROM tblApplicant;

R~
 
Just a few things so far:

1. get rid of
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
and use DoCmd.RunCommand acCmdSaveRecord (you don't want to use the menubar items as they can change (and do in Access 2007).
2. Your subform syntax is wrong in your on close event
Code:
[Forms]![frmInvestigator]![sfrmApplicant].Requery
should be
Code:
Forms!frmInvestigator.Form.sfrmApplicant.Requery

I'm still looking but I wanted to give you a head start on fixing things.
 
and the last part to make it work is get rid of the
Me.chkboxActive = -1
in the form's open event.
 
Almost forgot. The changes are stored automatically when you change a form, so the update button is not needed unless you want to make sure that they click it to save first. If so, you will need to put some code in the 2nd form's BeforeUpdate event to cancel if they close the form without clicking the update.

Code:
If Me.Dirty Then
  Me.Undo
End If
 
Bob..

Thank you very much... I got rid of the -1 but where can I put it so that the checkbox is always checked for a new person showing that it is active?

R~
 
You need to set it when entering a new person. So, if you want it set when a new record is added, set the DEFAULT value of the checkbox to be -1. That way it will add a new record with it as true but won't change an existing record.
 
Sorry, I didn't quite remember that the checkbox is on the applicant details when you open it and not when you add a new applicant.

You can add the checkbox into your applicant subform, set the default value in the properties as -1, and hide it and then when you add a new applicant it will add the checkbox and then it will be available when you open the other form.
 
Bob..

Thank you very much.. I am now getting a new error..... when I entered the code:

Code:
DoCmd.RunCommand accmdsaver

Here is the error: the runcommand action was canceled

R~
 

Users who are viewing this thread

Back
Top Bottom