Check Boxes on Forms

S

Secret Squirrel

I want to add a check box to a form that is used to tell a user when data has
been entered into a field on another form. The box with be checked when a
user enters data in a field on another form and unchecked when either there
is no data in this field or if the data is erased. Can this be done?
 
R

Rick B

A checkbox is just like any other field. It lives in the table, not in the
form. You would need to either have your user check and uncheck it when
needed, or write code to do the work for you. Then, simply display that
field in the forms, reports, or queries when you need it.
 
O

Ofer

If the first form is still open, where the data is open, then you can use
this code on the On Load event of form2

Me.CheckBoxName = not isnull(Forms![FirstFormName]![FieldName]

If the the first form is closed, then you can use the dlookup to check the
record

Me.CheckBoxName = not
isnull(dlookup("FieldName","TableName","WhereCondition"))
 
S

Secret Squirrel

I already have a macro running in the On Load event. Can I just add this to
the macro? If so how? And I'm a little unclear which form you are calling
"first form". Is that the one that has the data field or the one that has the
checkbox? They was users get to this data field is they click a command
button that brings them to another form. They then enter the data into a
field. When they go back to the original form I want the check box to show a
check mark stating there is data in the specific field on another form.

Ofer said:
If the first form is still open, where the data is open, then you can use
this code on the On Load event of form2

Me.CheckBoxName = not isnull(Forms![FirstFormName]![FieldName]

If the the first form is closed, then you can use the dlookup to check the
record

Me.CheckBoxName = not
isnull(dlookup("FieldName","TableName","WhereCondition"))

--
I hope that helped
Good luck


Secret Squirrel said:
I want to add a check box to a form that is used to tell a user when data has
been entered into a field on another form. The box with be checked when a
user enters data in a field on another form and unchecked when either there
is no data in this field or if the data is erased. Can this be done?
 
O

Ofer

Change the On load event to code instead of macro, and run the macro from the
code, that will give you more control over the macro you are running.

docmd.RunMacro "MacroName"
the rest of the code

You should use the dlookup, to look for the value entered or deleted from
tha table.

--
I hope that helped
Good luck


Secret Squirrel said:
I already have a macro running in the On Load event. Can I just add this to
the macro? If so how? And I'm a little unclear which form you are calling
"first form". Is that the one that has the data field or the one that has the
checkbox? They was users get to this data field is they click a command
button that brings them to another form. They then enter the data into a
field. When they go back to the original form I want the check box to show a
check mark stating there is data in the specific field on another form.

Ofer said:
If the first form is still open, where the data is open, then you can use
this code on the On Load event of form2

Me.CheckBoxName = not isnull(Forms![FirstFormName]![FieldName]

If the the first form is closed, then you can use the dlookup to check the
record

Me.CheckBoxName = not
isnull(dlookup("FieldName","TableName","WhereCondition"))

--
I hope that helped
Good luck


Secret Squirrel said:
I want to add a check box to a form that is used to tell a user when data has
been entered into a field on another form. The box with be checked when a
user enters data in a field on another form and unchecked when either there
is no data in this field or if the data is erased. Can this be done?
 
S

Secret Squirrel

How would I write a code to do the work for me? I'm not that good with check
boxes. I want there to be a check when data is entered into another field and
the check removed when either no data is there or when the data is cleared.
 
R

Rick B

In the form where the person is making the changes, make sure your checkbox
is on the form. I'd either make it locked or hidden so the person cannot
manually change it. In the field's before update, you'd put code like...

Private Sub SomeField_BeforeUpdate(Cancel As Integer)
If IsNull(SomeField) Then
SomeCheckBoxField = false
Else
SomeCheckBoxField = true
End If
End Sub


Hope that helps.
 
S

Secret Squirrel

Ok that worked the first time but now I when I go back in there it won't work
anymore. Why is that?

Here is how the code is:

Private Sub Text11_BeforeUpdate(Cancel As Integer)
If IsNull(Text11) Then
Check200 = False
Else
Check200 = True
End If

End Sub
 
R

Rick B

What do you mean, "the first time" and "when I go back in there" and "does
not work"?

It worked one time, but never again? It worked for one record, bit not
others? It sets the checkbox wrong? It does not change the checkbox at
all? It gives an error?
 
S

Secret Squirrel

After I put the code in there I tried it out and it worked. When I entered
data the check mark appeared and when I deleted the data the check mark
disappeared. But after that first time it stopped working. Does it matter
that the check box is on another form?
 
R

Rick B

What do you mean, "the checkmark is on another form"? The checkbox is a
field in the table.
 
S

Secret Squirrel

The checkbox is on another form. I need this checkbox to let users know when
there is data in a specific field on another form.
 
R

Rick B

You are not getting it. A field is stored in a TABLE, not a FORM. You can
display that field on a form (or several forms). If user A modifies a
record in form A, then you would update that checkbox using the code we
discussed. When user B pulls up that same record in form B (or form C, or
Form D, or on a report, or in a query...) they will see the checkbox.

Put that checkbox on any forms that you want to update it or view it. The
checkbox field lives in a table though, not in a form.
 
Top