Form problem

  • Thread starter Thread starter Jimmy
  • Start date Start date
J

Jimmy

I have the following problem:
In a form I have a text-box named "Akyra-reason" and a check box named
"Akyra".
What I want is whenever I enter any data at the text-box "Akyra-reason" I
want the check box "Akyra" to become clicked.
I tried in the after update of "Akyra-reason" the following but didn't work:

Private Sub AKYRA_REASON_AfterUpdate()
If Me![AKYRA-REASON] = Not Null Then
Me![AKYRA] = "-1"
End If
End Sub

I also tried....

Private Sub AKYRA_REASON_AfterUpdate()
If Me![AKYRA-REASON] = Not Null Then
Me![AKYRA] = "True"
End If
End Sub

But also nothing!
Can someone please help me.
Thank You in advance
Jimmy
 
Jimmy said:
I have the following problem:
In a form I have a text-box named "Akyra-reason" and a check box named
"Akyra".
What I want is whenever I enter any data at the text-box "Akyra-reason" I
want the check box "Akyra" to become clicked.
I tried in the after update of "Akyra-reason" the following but didn't work:

Private Sub AKYRA_REASON_AfterUpdate()
If Me![AKYRA-REASON] = Not Null Then
Me![AKYRA] = "-1"
End If
End Sub

I also tried....

Private Sub AKYRA_REASON_AfterUpdate()
If Me![AKYRA-REASON] = Not Null Then
Me![AKYRA] = "True"
End If
End Sub

But also nothing!
Can someone please help me.

"Not Null" is used in SQL/Queries, not in VBA code. You need to use the
IsNull() function instead.

Beyond that I would offer that your table design is not properly normalized. If
you want the [AKYRA] field to be True anytime the [AKYRA-REASON] field is
populated then you don't need the [AKYRA] field at all. You can simply test for
Null or Non-Null of the [AKYRA-REASON] field and get the same result as a Yes/No
field provides so having that field is redundant.

On your form you could have a CheckBox and instead of binding it to the field
[AKYRA], you just use a ControlSource of...

=Not IsNull([AKYRA-REASON])
 
Thanks Rick.
Well the problem is that we need the check mark to be stored in the table.
So if we use the =Not IsNull([AKYRA-REASON]) in "Akyra"
sourse it will not be stored but only viewed in the form, is that right? It
is possible in the future the field "AKYRA-REASON" may be deleted so we need
that check box.
As for the IsNull() function, I am new in Access so I don't quite know what
to write and where. Can you please give me some more information of ho to
write the IsNull() function code?
Thank you for your help
Jimmy


Rick Brandt said:
Jimmy said:
I have the following problem:
In a form I have a text-box named "Akyra-reason" and a check box named
"Akyra".
What I want is whenever I enter any data at the text-box "Akyra-reason"
I want the check box "Akyra" to become clicked.
I tried in the after update of "Akyra-reason" the following but didn't
work:

Private Sub AKYRA_REASON_AfterUpdate()
If Me![AKYRA-REASON] = Not Null Then
Me![AKYRA] = "-1"
End If
End Sub

I also tried....

Private Sub AKYRA_REASON_AfterUpdate()
If Me![AKYRA-REASON] = Not Null Then
Me![AKYRA] = "True"
End If
End Sub

But also nothing!
Can someone please help me.

"Not Null" is used in SQL/Queries, not in VBA code. You need to use the
IsNull() function instead.

Beyond that I would offer that your table design is not properly
normalized. If you want the [AKYRA] field to be True anytime the
[AKYRA-REASON] field is populated then you don't need the [AKYRA] field at
all. You can simply test for Null or Non-Null of the [AKYRA-REASON] field
and get the same result as a Yes/No field provides so having that field is
redundant.

On your form you could have a CheckBox and instead of binding it to the
field [AKYRA], you just use a ControlSource of...

=Not IsNull([AKYRA-REASON])
 
Jimmy said:
Thanks Rick.
Well the problem is that we need the check mark to be stored in the table.
So if we use the =Not IsNull([AKYRA-REASON]) in "Akyra"
sourse it will not be stored but only viewed in the form, is that right?

This premise is flawed. If you put the expression in a query you will have
exactly the same results using that query as if the value were stored in
the table and you used the table (except the former would be the correct
way to do it).
is possible in the future the field "AKYRA-REASON" may be deleted so we need
that check box.

You could of course add the Yes/no Field at the time the other field is
eliminated and populate it with an update query before deleting the other
field. So you still don't need the redundant field until such time that
the reason field is actually eliminated.
As for the IsNull() function, I am new in Access so I don't quite know what
to write and where. Can you please give me some more information of ho to
write the IsNull() function code?

Private Sub AKYRA_REASON_AfterUpdate()

Me![AKYRA] = Not IsNull(Me![AKYRA-REASON])

End Sub
 
Thanks Rick your help and advise was precious.


Rick Brandt said:
Jimmy said:
Thanks Rick.
Well the problem is that we need the check mark to be stored in the table.
So if we use the =Not IsNull([AKYRA-REASON]) in "Akyra"
sourse it will not be stored but only viewed in the form, is that right?

This premise is flawed. If you put the expression in a query you will
have
exactly the same results using that query as if the value were stored in
the table and you used the table (except the former would be the correct
way to do it).
is possible in the future the field "AKYRA-REASON" may be deleted so we need
that check box.

You could of course add the Yes/no Field at the time the other field is
eliminated and populate it with an update query before deleting the other
field. So you still don't need the redundant field until such time that
the reason field is actually eliminated.
As for the IsNull() function, I am new in Access so I don't quite know what
to write and where. Can you please give me some more information of ho to
write the IsNull() function code?

Private Sub AKYRA_REASON_AfterUpdate()

Me![AKYRA] = Not IsNull(Me![AKYRA-REASON])

End Sub
 
Back
Top