If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
How do I hide from view (and print), a selection of 6 labels and 5 boxes
from a report based on a condition of the data for each record. Eg. IIf(Mid[myfield],5,1)="G") I'm afraid I will need the exact syntax for this please. Also, based on an earlier reply to Cindy on this subject - I could not get the following to work in my report. Report Section - On Open - =[myfield].Visible=No [myfield] still displays!! Hope you can help... Thanks Steve |
#2
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
You can use the OnPrint event of the detail section where this text boxes
located in, write the code Me.[TextBoxName].Visible = Not (Mid([myfield],5,1) = "G" ) The same for the rest of the text boxes, just change the name -- Good Luck BS"D "Steve" wrote: How do I hide from view (and print), a selection of 6 labels and 5 boxes from a report based on a condition of the data for each record. Eg. IIf(Mid[myfield],5,1)="G") I'm afraid I will need the exact syntax for this please. Also, based on an earlier reply to Cindy on this subject - I could not get the following to work in my report. Report Section - On Open - =[myfield].Visible=No [myfield] still displays!! Hope you can help... Thanks Steve |
#3
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
Steve wrote:
How do I hide from view (and print), a selection of 6 labels and 5 boxes from a report based on a condition of the data for each record. Eg. IIf(Mid[myfield],5,1)="G") I'm afraid I will need the exact syntax for this please. Also, based on an earlier reply to Cindy on this subject - I could not get the following to work in my report. Report Section - On Open - =[myfield].Visible=No [myfield] still displays!! That's an expression. Where did you put it so it did not cause an error, in some property?? You need a line of VBA code in the report's Open event **procedure**: Me.[myfield].Visible=False The report's OnOpen property should have [Event Procedure] -- Marsh MVP [MS Access] |
#4
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
Thanks Ofer Cohen,
But this gives me an error - Can't find Macro "Me." I'm sure I have typed it as you have suggested. Also, are you suggesting I put muliple entries in the same line of the OnPrint event of the detail section for the rest of the text boxes. Are they separated by any character(s)? -- Steve "Ofer Cohen" wrote: You can use the OnPrint event of the detail section where this text boxes located in, write the code Me.[TextBoxName].Visible = Not (Mid([myfield],5,1) = "G" ) The same for the rest of the text boxes, just change the name -- Good Luck BS"D "Steve" wrote: How do I hide from view (and print), a selection of 6 labels and 5 boxes from a report based on a condition of the data for each record. Eg. IIf(Mid[myfield],5,1)="G") I'm afraid I will need the exact syntax for this please. Also, based on an earlier reply to Cindy on this subject - I could not get the following to work in my report. Report Section - On Open - =[myfield].Visible=No [myfield] still displays!! Hope you can help... Thanks Steve |
#5
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
Thanks Marshall,
Now I need the conditional IIf statement, but I can't get the syntax right. What I have below works, but I need the condition to be replaced/changed and based on the following - "IIf (Mid([DevelopmentNumber], 5, 1) = "G")" "Private Sub Report_Open(Cancel As Integer) If Me.DevelopmentNumber.Visible = True Then Me.Label31.Visible = False Me.Label32.Visible = False Me.Box36.Visible = False End If End Sub" Can you give me the right syntax please. -- Steve "Marshall Barton" wrote: Steve wrote: How do I hide from view (and print), a selection of 6 labels and 5 boxes from a report based on a condition of the data for each record. Eg. IIf(Mid[myfield],5,1)="G") I'm afraid I will need the exact syntax for this please. Also, based on an earlier reply to Cindy on this subject - I could not get the following to work in my report. Report Section - On Open - =[myfield].Visible=No [myfield] still displays!! That's an expression. Where did you put it so it did not cause an error, in some property?? You need a line of VBA code in the report's Open event **procedure**: Me.[myfield].Visible=False The report's OnOpen property should have [Event Procedure] -- Marsh MVP [MS Access] |
#6
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
Hi Steve,
Usually you get this error message when you enter this line directly in the property box, in that case Access looks for a macro. When the cursor located in the OmPrint property, there is a button with three dots, click it and select code view. In the code section enter the code sub ....() ' For each text box Me.[TextBox1Name].Visible = Not (Mid([myfield],5,1) = "G" ) Me.[TextBox2Name].Visible = Not (Mid([myfield],5,1) = "G" ) Me.[TextBox3Name].Visible = Not (Mid([myfield],5,1) = "G" ) End Sub The OnOpen event will work only once, when the report is loaded. The OnPrint event in the detail section will works for every record printed, so it will make the fields visible or not depend on the value of myfield in every record Good Luck BS"D "Steve" wrote in message ... Thanks Ofer Cohen, But this gives me an error - Can't find Macro "Me." I'm sure I have typed it as you have suggested. Also, are you suggesting I put muliple entries in the same line of the OnPrint event of the detail section for the rest of the text boxes. Are they separated by any character(s)? -- Steve "Ofer Cohen" wrote: You can use the OnPrint event of the detail section where this text boxes located in, write the code Me.[TextBoxName].Visible = Not (Mid([myfield],5,1) = "G" ) The same for the rest of the text boxes, just change the name -- Good Luck BS"D "Steve" wrote: How do I hide from view (and print), a selection of 6 labels and 5 boxes from a report based on a condition of the data for each record. Eg. IIf(Mid[myfield],5,1)="G") I'm afraid I will need the exact syntax for this please. Also, based on an earlier reply to Cindy on this subject - I could not get the following to work in my report. Report Section - On Open - =[myfield].Visible=No [myfield] still displays!! Hope you can help... Thanks Steve |
#7
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
Steve wrote:
Now I need the conditional IIf statement, but I can't get the syntax right. What I have below works, but I need the condition to be replaced/changed and based on the following - "IIf (Mid([DevelopmentNumber], 5, 1) = "G")" "Private Sub Report_Open(Cancel As Integer) If Me.DevelopmentNumber.Visible = True Then Me.Label31.Visible = False Me.Label32.Visible = False Me.Box36.Visible = False End If End Sub" that code does not relate to your question. What effect are you trying to get? The best I can say at this point is that Ofer already explained how to do what I'm guessing you want. -- Marsh MVP [MS Access] |
#8
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
Thanks Heaps Offer - this worked a treat. Very much appreciated your
assistance. How good is this facility! -- Aussie Steve "Ofer Cohen" wrote: Hi Steve, Usually you get this error message when you enter this line directly in the property box, in that case Access looks for a macro. When the cursor located in the OmPrint property, there is a button with three dots, click it and select code view. In the code section enter the code sub ....() ' For each text box Me.[TextBox1Name].Visible = Not (Mid([myfield],5,1) = "G" ) Me.[TextBox2Name].Visible = Not (Mid([myfield],5,1) = "G" ) Me.[TextBox3Name].Visible = Not (Mid([myfield],5,1) = "G" ) End Sub The OnOpen event will work only once, when the report is loaded. The OnPrint event in the detail section will works for every record printed, so it will make the fields visible or not depend on the value of myfield in every record Good Luck BS"D "Steve" wrote in message ... Thanks Ofer Cohen, But this gives me an error - Can't find Macro "Me." I'm sure I have typed it as you have suggested. Also, are you suggesting I put muliple entries in the same line of the OnPrint event of the detail section for the rest of the text boxes. Are they separated by any character(s)? -- Steve "Ofer Cohen" wrote: You can use the OnPrint event of the detail section where this text boxes located in, write the code Me.[TextBoxName].Visible = Not (Mid([myfield],5,1) = "G" ) The same for the rest of the text boxes, just change the name -- Good Luck BS"D "Steve" wrote: How do I hide from view (and print), a selection of 6 labels and 5 boxes from a report based on a condition of the data for each record. Eg. IIf(Mid[myfield],5,1)="G") I'm afraid I will need the exact syntax for this please. Also, based on an earlier reply to Cindy on this subject - I could not get the following to work in my report. Report Section - On Open - =[myfield].Visible=No [myfield] still displays!! Hope you can help... Thanks Steve |
#9
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
Thanks Marshall - it appears that I can achieve what I want 2 different ways
and yes I've followed Offer's suggestion which is working for me. I was interested in trying your way also with the approriate If statement based on the Mid() function, as previously explained. No matter now. -- Steve "Marshall Barton" wrote: Steve wrote: Now I need the conditional IIf statement, but I can't get the syntax right. What I have below works, but I need the condition to be replaced/changed and based on the following - "IIf (Mid([DevelopmentNumber], 5, 1) = "G")" "Private Sub Report_Open(Cancel As Integer) If Me.DevelopmentNumber.Visible = True Then Me.Label31.Visible = False Me.Label32.Visible = False Me.Box36.Visible = False End If End Sub" that code does not relate to your question. What effect are you trying to get? The best I can say at this point is that Ofer already explained how to do what I'm guessing you want. -- Marsh MVP [MS Access] |
#10
|
|||
|
|||
Printing Selective Fields,Labels and Boxes in a Report.
Steve wrote:
Thanks Marshall - it appears that I can achieve what I want 2 different ways and yes I've followed Offer's suggestion which is working for me. I was interested in trying your way also with the approriate If statement based on the Mid() function, as previously explained. No matter now. Once I figured out what you were trying to do, I would have suggested the same thing Ofer said. There are other code sequences that will accomplish the same thing, but they would have more lines of code to no benefit in your case. -- Marsh MVP [MS Access] |
Thread Tools | |
Display Modes | |
|
|