Place check in box using code

  • Thread starter Thread starter NewSysAdmin
  • Start date Start date
N

NewSysAdmin

Hello-
I'm trying to create 2 check boxes for Yes and No which I'd like one to be
checked automatically based on the report. I'd like the check box for yes to
be checked if there are records for the report. If there are no records, I'd
like the No box to be checked.

Here is my code for the No box. If there is no customer name listed, it
means there are no records in the report. "
=IIf(IsNull([CustomerName]),True) "

This code does not do anything. Can someone please guide me in the right
direction? Thank you.
 
That's because "true" to a check box = -1 and false = 0. Try your iif
statement with -1 and 0
 
I didn't like the look on my report of the check boxes, I preferred an
actual word "yes" or "no" . My form uses a checkbox for easy data entry
tho. So what I did in the underlying query in the report was set my yes/no
field value to this: insp: IIf([finsp]=-1,"Yes"," No") which converts
the checkbox yes value (-1) to Yes/No and then used a text box in the report
with a control source set to =[insp]. Looks much nicer than the check box.
;) then I could chew out the drivers for not turning in their logs and/or
inspections as the case may be! This was set up in Access 2003, but I
certainly hope it will work in Access 2007, which I installed on my computer
Friday 08/22/08 and I started reprogramming/updating my databases Friday
evening. Will let you know if it works!


Golfinray said:
That's because "true" to a check box = -1 and false = 0. Try your iif
statement with -1 and 0

NewSysAdmin said:
Hello-
I'm trying to create 2 check boxes for Yes and No which I'd like one to
be
checked automatically based on the report. I'd like the check box for
yes to
be checked if there are records for the report. If there are no records,
I'd
like the No box to be checked.

Here is my code for the No box. If there is no customer name listed, it
means there are no records in the report. "
=IIf(IsNull([CustomerName]),True) "

This code does not do anything. Can someone please guide me in the right
direction? Thank you.
 
Thanks for your responses. I decided to change my report. If there is no
data/no records, I'd like to display the word "No" in a text box (Text150).
If there is data, I'd like to display "yes" in the same box if possible.

Here is my code in the report's no data section.

Private Sub Report_NoData(Cancel As Integer)
Report_Type_A_Report_New.Text150 = "No"
End Sub

I am not sure where to put the word "yes". As it is now, it displays "no"
even if there is data.

Any suggestions? Thank you.

Regina Parker said:
I didn't like the look on my report of the check boxes, I preferred an
actual word "yes" or "no" . My form uses a checkbox for easy data entry
tho. So what I did in the underlying query in the report was set my yes/no
field value to this: insp: IIf([finsp]=-1,"Yes"," No") which converts
the checkbox yes value (-1) to Yes/No and then used a text box in the report
with a control source set to =[insp]. Looks much nicer than the check box.
;) then I could chew out the drivers for not turning in their logs and/or
inspections as the case may be! This was set up in Access 2003, but I
certainly hope it will work in Access 2007, which I installed on my computer
Friday 08/22/08 and I started reprogramming/updating my databases Friday
evening. Will let you know if it works!


Golfinray said:
That's because "true" to a check box = -1 and false = 0. Try your iif
statement with -1 and 0

NewSysAdmin said:
Hello-
I'm trying to create 2 check boxes for Yes and No which I'd like one to
be
checked automatically based on the report. I'd like the check box for
yes to
be checked if there are records for the report. If there are no records,
I'd
like the No box to be checked.

Here is my code for the No box. If there is no customer name listed, it
means there are no records in the report. "
=IIf(IsNull([CustomerName]),True) "

This code does not do anything. Can someone please guide me in the right
direction? Thank you.
 
Back
Top