Create Reports Based on Yes/No Check Box

  • Thread starter Thread starter Brook
  • Start date Start date
B

Brook

I have a form that has a check box on it called
CreateLabels. When checked, I want to be able to click on
a command button "Create Labels" and have my
rtpCustomLabels Print to screen.

I am unsure how to set up the command button to only read
those check boxes "createLabels" that are "yes/true"?

Also,
I would like to checkbox to be reset to unchecked after
the report is printed?

Thanks in advance,

Brook
 
Brook,

It looks like you need to read the state of the check boxes and take some
action based on on that state.

The code for tbe On Click event for your button might look like this.

If Me.CreateLabels = True Then
DoCmd.OpenReport "rtpCustomLabels", acPreview
Me.CreateLabels = False
End If

This will read the state of the checkbox named CreateLabels and preview the
report if it's checked.

Greg
 
What does it mean if I am getting an error message:

Run-Time Error "438"

Object doesn't support this object or method?

Brook
 
I have a form that has a check box on it called
CreateLabels. When checked, I want to be able to click on
a command button "Create Labels" and have my
rtpCustomLabels Print to screen.

I am unsure how to set up the command button to only read
those check boxes "createLabels" that are "yes/true"?

Also,
I would like to checkbox to be reset to unchecked after
the report is printed?

Thanks in advance,

Brook

Is this what you are trying to do?
You already have a label report created and you wish to print labels
for only those records you have checked on your form.

If so, add a check box field to the table.
Let's name it "Selected".

Drag the Selected field onto your form.

Now when you check the Selected check box, a tick mark will appear in
each record chosen.

Code the Command Button on the form:
DoCmd.OpenReport "rtpCustomLabels Print", acViewPreview, ,"[Selected]
= -1"

Change acViewPreview to acViewNormal to print the labels without
Preview.

After the labels are SUCCESSFULLY printed, you can clear the check
boxes by using an update query (in a different command button):

CurrentDb.Execute "Update YourTable Set YourTable.Selected =
0;",dbFailOnError

Change the table and field names as needed.
 
Ok,

Here is what I accomplished:

I created a qry to pull all the records that
have "CreateLabel" checked.

I created a report based on this qry.

On my form I created a command button to open and preview
the report based on the qry mentioned above, then when I
close the report I run an update qry to change all my
CreateLabel = True to False.

The only thing I am running into now, is that if I stay
in the form without moving to another record and then
check my CreateLabel Check box then click my
CreateLabelButton, I am getting my message that there are
no labels to preview.

At this point, I think that I need some sort of funtion
to run my qryRugLabels? Is there a way to set this up so
that when I check my box "Createlabels" that a "Requery"
runs?

Thanks,

Brook
 
Brook,

It looks like you need to save the record before you run the report. The
forms don't save the current record until you move to another record or
explicitly save it like this.

If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If

Add that code to the CreateLabelButton On Click event handler.

Greg
 
Back
Top