Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Report

Status
Not open for further replies.

Rjconrep

Technical User
Oct 24, 2000
66
US
I have a form where you input information for scheduling. I have a checkbox on this form that lets people in certain departments know that their material is here. I want to be able to update a text box on my report based on whether the check box in my form is checked.

Here is what I have:

Private Sub ckMatHere_Click()
If ckMatHere = -1 Then
Reports![5_MailRoom]!text74 = "X"
Else: Reports![5_MailRoom]!text74 = " "
End If

End Sub
 
Hi,
This code actually belongs in the detail section of the report. The report is not yet open!!!

In the report, you will add the code to the OnFormat event for the detail section, or wherever you are placing the textbox for the "x". HTH, [pc2]
Randy Smith
California Teachers Association
 
It is not working for me. I know this has to be a simple fix but it is totally missing me right now.
 
Hi,
You have tried to set the value of a textbox on the report using the clicked event for a check box (e.g., "Private Sub ckMatHere_Click()"). Unfortunately, that will not work because the report hasn't opened yet. And, even if the report was open, it still wouldn't work because displaying the "X" is dependent on each record being printed.
Instead, you can place this code in the report.

1) Open the report in Design View, and select the section where the "X" is to appear. In 99% of the instances, this will be in the detail section. To select any given section, such as the detail, click on the small square box on the far left side (inside the vertical ruler bar). After doing this, the entire divider line will change to a black background.
2) Right click on the black divider line, and select Properties. Click on the Event tab, and select On Format. Go to the right side and click the 3 dots (e.g., ...). Choose the code builder.
3) Enter your code there. If probably should look like this:
If ckMatHere = True Then
txtMailRoomChecked = "X"
Else
txtMailRoomChecked = " "
End If
This presumes that the textbox you added to the report is called "txtMailRoomChecked".


HTH, [pc2]
Randy Smith
California Teachers Association
 
Here is what I have in the detailed section of my report.
It still isn't working.

Private Sub Detail2_Format(Cancel As Integer, FormatCount As Integer)

If Forms![Job Data Entry]!ckMatHere = true Then
Text74 = "X"
Else
Text74 = " "
End If

End Sub

Am I still missing something?
 
Hi,
No, this code is not correct.
"If Forms![Job Data Entry]!ckMatHere = true Then..."

The OnFormat event in the Detail section of the report will look at the values of each and every record. You don't want to use some value from a form, because that is not indicative of each record being printed. Does this make sense?

I presume you are printing many records, and some of them may be checked, and others are not checked. Is this correct?

If so, then you will have a textbox in the Detail section from your table that could be called txtMailRoomChecked (use the name coming from your table). You should probably set the Visible property of this to No, so that you can provide your own textbox that shows "X" or " ".

On the other hand, if you wish to print only those records that are checked (or unchecked), then you may want to use "filter". I wrote an FAQ on that topic if this is what you want. Just let me know, ok?
HTH, [pc2]
Randy Smith
California Teachers Association
 
OK..Now I think we are on the same page.
However, the reason I am not binding the text box to the table is because sometimes the field in my report called Material Here will have data already in it coming from the table. I need to be able to put an "X" over what's already in the field. Does that make sense.

A better explaination.
Each department is alloted a certain amount of time to finish a job. Sometimes there are several process in each department that need to be done. There is a text box on the report that shows how much time will be needed to complete a certain process in each dept. I want to be able to put in "X" in the box over the time to show that that process has been completed. The text box with the time alloted in it is bound to a table already. I know that I can't have a text box pull from two different fields at the same time...there in lies my problem. Do you have any suggestions?
 
Hi,
As I said the my last post, set your bound field (Material Here) to have the Visible property set to No. (you need to keep the field on the report, so that it is usable in your formulas)
That way, you can replace it with your own new textbox that may or may not have an "X" in it. In fact, you can even do more with this textbox. You can set the property to bold if it is "X". HTH, [pc2]
Randy Smith
California Teachers Association
 
Thanks for all of your help! I couldn't have done it without you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top