Yes/No Condition

  • Thread starter 2Blessed4Stress
  • Start date
2

2Blessed4Stress

I have a form where the user selects a cars name by using a yes/no checkbox.
The form is based on a query that sorts the records based on other fields. I
do not have any criteria in my query.
Once the user selects the cars, they click 1 of 3 comand buttons to do the
next step. (The command buttons run off of a macro) This works fine. In my
macro I have a Condition:
[select]=No/ MSG Box-"You must select one car", then stops the macro. This
works fine. The problem is once the user goes to the next step and then
chooses to go back to this selection screen. The same MSG appears even
though on the screen you see the same cars check. I'm not sure if it's in my
condition or what.
 
S

Steve Schapel

Blessed,

I had assumed your macro was assigned on the Click event of the command
button. Is that right? If the macro is being activated when the user
returns to the form, it sounds like the same macro may also be on another
event as well. For example the Open or Load or Activate or Current event of
the form.

By the way, if I understand you correctly, if this is a continuous view
form, that macro Condition will reference the value of the [select] field in
the form's current record, probably the first record unless you have
explicitly moved to another.
 
2

2Blessed4Stress

Yes it's on the click event of the command button. This is what I have on
the on activate event:

Private Sub Form_Activate()
DoCmd.Restore
End Sub

Yes this is a continuous view form and I think you're on to something with
the referencing the 1st record. If I choose cars #2 and #3, click the
command button to the next screen and then go back to the selection screen,
it doesn't recognize 2 and 3 being checked. If I have #1 checked, it's fine.
How can I fix it?

Steve Schapel said:
Blessed,

I had assumed your macro was assigned on the Click event of the command
button. Is that right? If the macro is being activated when the user
returns to the form, it sounds like the same macro may also be on another
event as well. For example the Open or Load or Activate or Current event of
the form.

By the way, if I understand you correctly, if this is a continuous view
form, that macro Condition will reference the value of the [select] field in
the form's current record, probably the first record unless you have
explicitly moved to another.

--
Steve Schapel, Microsoft Access MVP


2Blessed4Stress said:
I have a form where the user selects a cars name by using a yes/no
checkbox.
The form is based on a query that sorts the records based on other fields.
I
do not have any criteria in my query.
Once the user selects the cars, they click 1 of 3 comand buttons to do the
next step. (The command buttons run off of a macro) This works fine. In
my
macro I have a Condition:
[select]=No/ MSG Box-"You must select one car", then stops the macro.
This
works fine. The problem is once the user goes to the next step and then
chooses to go back to this selection screen. The same MSG appears even
though on the screen you see the same cars check. I'm not sure if it's in
my
condition or what.
 
S

Steve Schapel

Blessed,

Ah, I see. Try changing the macro Condition to:
DCount("*","NameOfYourTable","[select]=No")>0
 
2

2Blessed4Stress

It's not working. It doesn't recognize that something has been checked and
gives the built in Message "You must select one car". The form is built from
a qry. I tried using the qry name as well as the table name that the qry is
based on.

Steve Schapel said:
Blessed,

Ah, I see. Try changing the macro Condition to:
DCount("*","NameOfYourTable","[select]=No")>0

--
Steve Schapel, Microsoft Access MVP


2Blessed4Stress said:
Yes it's on the click event of the command button. This is what I have on
the on activate event:

Private Sub Form_Activate()
DoCmd.Restore
End Sub

Yes this is a continuous view form and I think you're on to something with
the referencing the 1st record. If I choose cars #2 and #3, click the
command button to the next screen and then go back to the selection
screen,
it doesn't recognize 2 and 3 being checked. If I have #1 checked, it's
fine.
How can I fix it?
 
S

Steve Schapel

Blessed,

Well, it was only meant to be an example. Sorry. I'm not really sure what
you are actually trying to do, or what actions are in your macro. Try and
think it through. If what you want is for the message box to pop up of
there are no records selected, then probably the Condition is more likely to
be like this:
DCount("*","NameOfYourQuery","[select]=Yes")=0
 
2

2Blessed4Stress

This did it! Changing the No to a Yes and the > sign to = in your last
example. Thanks a million!!!!

Steve Schapel said:
Blessed,

Well, it was only meant to be an example. Sorry. I'm not really sure what
you are actually trying to do, or what actions are in your macro. Try and
think it through. If what you want is for the message box to pop up of
there are no records selected, then probably the Condition is more likely to
be like this:
DCount("*","NameOfYourQuery","[select]=Yes")=0

--
Steve Schapel, Microsoft Access MVP


2Blessed4Stress said:
It's not working. It doesn't recognize that something has been checked
and
gives the built in Message "You must select one car". The form is built
from
a qry. I tried using the qry name as well as the table name that the qry
is
based on.
 
S

Steve Schapel

Thanks, Blessed. Well, I would be gratified to think that you understood
*why*, or what the meaning is, so that you can work it out yourself next
time. :)
 

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