Using "Like" on a form

R

Robert Gillard

I am trying to build a form to help my daughter revise for her Latin exams.
I have a table showing the Latin and then a translation of it and finally an
empty column for the answer. However some words have several meanings i.e.
the correct answer may be "slave, servant" if my daughter enters "slave " I
want it to show as correct.
I have a form showing the Latin word, the answer is "not visible" and then
the empty column (Laura) for my daughters answer, followed by an unbound box
(text8) in which "correct" or "wrong" will appear after my daughter inputs
her answer and presses enter. In simple English what I want to say is if the
answer is correct show "correct" and make the "not visible" field visible.
If the answer is not correct "wrong"appears and the curser returns to the
previous field (Laura).

IIf([Laura]Like"*" & [Answer] & "*","correct"and [Answer] isvisible,"wrong")

Sorry my knowledge is very limited. Any help gratefully received.

Bob
 
D

Dan Artuso

Hi,
Something like this should work:

If Me.Laura Like "*" & Me.Answer & "*" Then
Me.text8 = "correct"
Me.Answer.Visible = True
Else

Me.text8 = "wrong"
Me.Answer.Visible = False
Me.Laura.SetFocus
End If

I would put this code in the click event of a command button and make it the 'default' by
going to the button's property sheet and on the Other tab, put yes in the Default property.
That way hitting the enter key will run the button's code.

HTH
Dan Artuso, Access MVP
 
R

Robert Gillard

Dan,
Thank you, "we" are nearly there.

I set the form to "FORM VIEW" so my daughter could see about 20
questions at a time. This has now raised a 2nd problem, when a question is
correct / wrong it marks all questions as right ( or wrong) If I add a "auto
number" to each row is it possible to mark each row seperateltly.? Again I
must ask how

With grateful thanks

Bob





Dan Artuso said:
Hi,
Something like this should work:

If Me.Laura Like "*" & Me.Answer & "*" Then
Me.text8 = "correct"
Me.Answer.Visible = True
Else

Me.text8 = "wrong"
Me.Answer.Visible = False
Me.Laura.SetFocus
End If

I would put this code in the click event of a command button and make it the 'default' by
going to the button's property sheet and on the Other tab, put yes in the Default property.
That way hitting the enter key will run the button's code.

HTH
Dan Artuso, Access MVP


I am trying to build a form to help my daughter revise for her Latin exams.
I have a table showing the Latin and then a translation of it and finally an
empty column for the answer. However some words have several meanings i.e.
the correct answer may be "slave, servant" if my daughter enters "slave " I
want it to show as correct.
I have a form showing the Latin word, the answer is "not visible" and then
the empty column (Laura) for my daughters answer, followed by an unbound box
(text8) in which "correct" or "wrong" will appear after my daughter inputs
her answer and presses enter. In simple English what I want to say is if the
answer is correct show "correct" and make the "not visible" field visible.
If the answer is not correct "wrong"appears and the curser returns to the
previous field (Laura).

IIf([Laura]Like"*" & [Answer] & "*","correct"and [Answer] isvisible,"wrong")

Sorry my knowledge is very limited. Any help gratefully received.

Bob
 
F

fredg

Dan,
Thank you, "we" are nearly there.

I set the form to "FORM VIEW" so my daughter could see about 20
questions at a time. This has now raised a 2nd problem, when a question is
correct / wrong it marks all questions as right ( or wrong) If I add a "auto
number" to each row is it possible to mark each row seperateltly.? Again I
must ask how

With grateful thanks

Bob





Dan Artuso said:
Hi,
Something like this should work:

If Me.Laura Like "*" & Me.Answer & "*" Then
Me.text8 = "correct"
Me.Answer.Visible = True
Else

Me.text8 = "wrong"
Me.Answer.Visible = False
Me.Laura.SetFocus
End If

I would put this code in the click event of a command button and make it the 'default' by
going to the button's property sheet and on the Other tab, put yes in the Default property.
That way hitting the enter key will run the button's code.

HTH
Dan Artuso, Access MVP


I am trying to build a form to help my daughter revise for her Latin exams.
I have a table showing the Latin and then a translation of it and finally an
empty column for the answer. However some words have several meanings i.e.
the correct answer may be "slave, servant" if my daughter enters "slave " I
want it to show as correct.
I have a form showing the Latin word, the answer is "not visible" and then
the empty column (Laura) for my daughters answer, followed by an unbound box
(text8) in which "correct" or "wrong" will appear after my daughter inputs
her answer and presses enter. In simple English what I want to say is if the
answer is correct show "correct" and make the "not visible" field visible.
If the answer is not correct "wrong"appears and the curser returns to the
previous field (Laura).

IIf([Laura]Like"*" & [Answer] & "*","correct"and [Answer] isvisible,"wrong")

Sorry my knowledge is very limited. Any help gratefully received.

Bob
Bob,
You need to add the field to the table first. Then add the field to
the form.
Now the field is bound to the corresponding record and each row will
display it's own 'correct' or 'wrong' answer result.
 
R

Robert Gillard

Fred,
I have tried that but it makes no difference, still everything changes
right or wrong.

Bob


fredg said:
Dan,
Thank you, "we" are nearly there.

I set the form to "FORM VIEW" so my daughter could see about 20
questions at a time. This has now raised a 2nd problem, when a question is
correct / wrong it marks all questions as right ( or wrong) If I add a "auto
number" to each row is it possible to mark each row seperateltly.? Again I
must ask how

With grateful thanks

Bob





Dan Artuso said:
Hi,
Something like this should work:

If Me.Laura Like "*" & Me.Answer & "*" Then
Me.text8 = "correct"
Me.Answer.Visible = True
Else

Me.text8 = "wrong"
Me.Answer.Visible = False
Me.Laura.SetFocus
End If

I would put this code in the click event of a command button and make
it
the 'default' by
going to the button's property sheet and on the Other tab, put yes in
the
Default property.
That way hitting the enter key will run the button's code.

HTH
Dan Artuso, Access MVP


I am trying to build a form to help my daughter revise for her Latin exams.
I have a table showing the Latin and then a translation of it and finally an
empty column for the answer. However some words have several meanings i.e.
the correct answer may be "slave, servant" if my daughter enters
"slave
" I
want it to show as correct.
I have a form showing the Latin word, the answer is "not visible" and then
the empty column (Laura) for my daughters answer, followed by an
unbound
box
(text8) in which "correct" or "wrong" will appear after my daughter inputs
her answer and presses enter. In simple English what I want to say is
if
the
answer is correct show "correct" and make the "not visible" field visible.
If the answer is not correct "wrong"appears and the curser returns to the
previous field (Laura).

IIf([Laura]Like"*" & [Answer] & "*","correct"and [Answer] isvisible,"wrong")

Sorry my knowledge is very limited. Any help gratefully received.

Bob
Bob,
You need to add the field to the table first. Then add the field to
the form.
Now the field is bound to the corresponding record and each row will
display it's own 'correct' or 'wrong' answer result.
 
B

Bruce

Did you copy the controls (text boxes)? If so, maybe you
didn't change enough properties in the copies. It sounds
as if all of the controls are bound to the same field.
Check the control source for each individual control that
displays the undesirable behavior.
-----Original Message-----
Fred,
I have tried that but it makes no difference, still everything changes
right or wrong.

Bob


problem, when a question
is wrong) If I add a
"auto seperateltly.? Again
I command button and make
it Other tab, put yes in
the daughter enters
"slave followed by an
unbound what I want to say is
if
the
answer is correct show "correct" and make the "not visible" field
visible.
If the answer is not correct "wrong"appears and the curser returns to
the
previous field (Laura).

IIf([Laura]Like"*" & [Answer] & "*","correct"and [Answer]
isvisible,"wrong")

Sorry my knowledge is very limited. Any help gratefully received.

Bob
Bob,
You need to add the field to the table first. Then add the field to
the form.
Now the field is bound to the corresponding record and each row will
display it's own 'correct' or 'wrong' answer result.


.
 
D

Dan Artuso

Hi,
I didn't know you were using a continuous form. That makes a difference.
Make sure all your controls are bound to a field in the form's underlying
query or table. This means that every control should have a Control Source set on
it's property sheet.

Then try just putting the code in the After Update event of your Answer text box.
Then, by tabbing out of the Answer control the code will run. You should only text8
for the current record updated. If you still see all of them change then text8 is still unbound.
--
HTH
Dan Artuso, Access MVP


Robert Gillard said:
Fred,
I have tried that but it makes no difference, still everything changes
right or wrong.

Bob


fredg said:
Dan,
Thank you, "we" are nearly there.

I set the form to "FORM VIEW" so my daughter could see about 20
questions at a time. This has now raised a 2nd problem, when a question is
correct / wrong it marks all questions as right ( or wrong) If I add a "auto
number" to each row is it possible to mark each row seperateltly.? Again I
must ask how

With grateful thanks

Bob





Hi,
Something like this should work:

If Me.Laura Like "*" & Me.Answer & "*" Then
Me.text8 = "correct"
Me.Answer.Visible = True
Else

Me.text8 = "wrong"
Me.Answer.Visible = False
Me.Laura.SetFocus
End If

I would put this code in the click event of a command button and make it
the 'default' by
going to the button's property sheet and on the Other tab, put yes in the
Default property.
That way hitting the enter key will run the button's code.

HTH
Dan Artuso, Access MVP


I am trying to build a form to help my daughter revise for her Latin
exams.
I have a table showing the Latin and then a translation of it and
finally an
empty column for the answer. However some words have several meanings
i.e.
the correct answer may be "slave, servant" if my daughter enters "slave
" I
want it to show as correct.
I have a form showing the Latin word, the answer is "not visible" and
then
the empty column (Laura) for my daughters answer, followed by an unbound
box
(text8) in which "correct" or "wrong" will appear after my daughter
inputs
her answer and presses enter. In simple English what I want to say is if
the
answer is correct show "correct" and make the "not visible" field
visible.
If the answer is not correct "wrong"appears and the curser returns to
the
previous field (Laura).

IIf([Laura]Like"*" & [Answer] & "*","correct"and [Answer]
isvisible,"wrong")

Sorry my knowledge is very limited. Any help gratefully received.

Bob
Bob,
You need to add the field to the table first. Then add the field to
the form.
Now the field is bound to the corresponding record and each row will
display it's own 'correct' or 'wrong' answer result.
 
R

Robert Gillard

In order to get this to work I have built a fresh table with just 5 fields

refno,
Latin,
Correct_Answer
Laura (this is where my daughter types in her answer)
rw (this shows as correct or wrong)

I have put all fields into a query and then based the form (continuous) on
that query.

As suggested I have set the following code to run After Update

If Me.Laura Like "*" & Me.Correct_Answer & "*" Then
Me.rw = "correct"
Me.Correct_Answer.Visible = True
Else

Me.rw = "wrong"
Me.Correct_Answer.Visible = False
Me.Laura.SetFocus
End If

I still have two issues
1. If the answer is right (or wrong) it resets the whole column
Correct_Answer to visible (or hiden). As you appreciate if you get the first
question correct suddenly all of the answers appear to all of the other
questions.... which makes the test much easier
2. "Like" still does not work, In the field Correct_Answer there may be two
or three words seperated by a comma such as "slave, servant, help". If my
daughter tyes in any one of them I need it to show as correct. At the
moment you need to get all the words in the right order Plus commas) befor
it will show as correct.

Dan Artuso said:
Hi,
I didn't know you were using a continuous form. That makes a difference.
Make sure all your controls are bound to a field in the form's underlying
query or table. This means that every control should have a Control Source set on
it's property sheet.

Then try just putting the code in the After Update event of your Answer text box.
Then, by tabbing out of the Answer control the code will run. You should only text8
for the current record updated. If you still see all of them change then text8 is still unbound.
--
HTH
Dan Artuso, Access MVP


Fred,
I have tried that but it makes no difference, still everything changes
right or wrong.

Bob


fredg said:
On Tue, 24 Feb 2004 00:18:24 GMT, Robert Gillard wrote:

Dan,
Thank you, "we" are nearly there.

I set the form to "FORM VIEW" so my daughter could see about 20
questions at a time. This has now raised a 2nd problem, when a
question
is
correct / wrong it marks all questions as right ( or wrong) If I add
a
"auto
number" to each row is it possible to mark each row seperateltly.?
Again
I
must ask how

With grateful thanks

Bob





Hi,
Something like this should work:

If Me.Laura Like "*" & Me.Answer & "*" Then
Me.text8 = "correct"
Me.Answer.Visible = True
Else

Me.text8 = "wrong"
Me.Answer.Visible = False
Me.Laura.SetFocus
End If

I would put this code in the click event of a command button and
make
it
the 'default' by
going to the button's property sheet and on the Other tab, put yes
in
the
Default property.
That way hitting the enter key will run the button's code.

HTH
Dan Artuso, Access MVP


I am trying to build a form to help my daughter revise for her Latin
exams.
I have a table showing the Latin and then a translation of it and
finally an
empty column for the answer. However some words have several meanings
i.e.
the correct answer may be "slave, servant" if my daughter enters "slave
" I
want it to show as correct.
I have a form showing the Latin word, the answer is "not visible" and
then
the empty column (Laura) for my daughters answer, followed by an unbound
box
(text8) in which "correct" or "wrong" will appear after my daughter
inputs
her answer and presses enter. In simple English what I want to say
is
if
the
answer is correct show "correct" and make the "not visible" field
visible.
If the answer is not correct "wrong"appears and the curser returns to
the
previous field (Laura).

IIf([Laura]Like"*" & [Answer] & "*","correct"and [Answer]
isvisible,"wrong")

Sorry my knowledge is very limited. Any help gratefully received.

Bob
Bob,
You need to add the field to the table first. Then add the field to
the form.
Now the field is bound to the corresponding record and each row will
display it's own 'correct' or 'wrong' answer result.
 
R

Robert Gillard

Sorry sorted problem 2, but still left with problem 1. - the appearing
answers.!!
Is there a better way to approach this issue.

Bob


Robert Gillard said:
In order to get this to work I have built a fresh table with just 5 fields

refno,
Latin,
Correct_Answer
Laura (this is where my daughter types in her answer)
rw (this shows as correct or wrong)

I have put all fields into a query and then based the form (continuous) on
that query.

As suggested I have set the following code to run After Update

If Me.Laura Like "*" & Me.Correct_Answer & "*" Then
Me.rw = "correct"
Me.Correct_Answer.Visible = True
Else

Me.rw = "wrong"
Me.Correct_Answer.Visible = False
Me.Laura.SetFocus
End If

I still have two issues
1. If the answer is right (or wrong) it resets the whole column
Correct_Answer to visible (or hiden). As you appreciate if you get the first
question correct suddenly all of the answers appear to all of the other
questions.... which makes the test much easier
2. "Like" still does not work, In the field Correct_Answer there may be two
or three words seperated by a comma such as "slave, servant, help". If my
daughter tyes in any one of them I need it to show as correct. At the
moment you need to get all the words in the right order Plus commas) befor
it will show as correct.

Dan Artuso said:
Hi,
I didn't know you were using a continuous form. That makes a difference.
Make sure all your controls are bound to a field in the form's underlying
query or table. This means that every control should have a Control
Source
set on
it's property sheet.

Then try just putting the code in the After Update event of your Answer text box.
Then, by tabbing out of the Answer control the code will run. You should only text8
for the current record updated. If you still see all of them change then text8 is still unbound.
add
yes
visible"
say
returns
to
the
previous field (Laura).

IIf([Laura]Like"*" & [Answer] & "*","correct"and [Answer]
isvisible,"wrong")

Sorry my knowledge is very limited. Any help gratefully received.

Bob
Bob,
You need to add the field to the table first. Then add the field to
the form.
Now the field is bound to the corresponding record and each row will
display it's own 'correct' or 'wrong' answer result.
 

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