Printing Selective Fields,Labels and Boxes in a Report.

G

Guest

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
 
G

Guest

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
 
M

Marshall Barton

Steve said:
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]
 
G

Guest

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 said:
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 said:
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
 
G

Guest

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 said:
Steve said:
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]
 
O

Ofer Cohen

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 said:
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 said:
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 said:
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
 
M

Marshall Barton

Steve said:
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.
 
G

Guest

Thanks Heaps Offer - this worked a treat. Very much appreciated your
assistance.
How good is this facility!
--
Aussie Steve


Ofer Cohen said:
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 said:
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 said:
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


:

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
 
G

Guest

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 said:
Steve said:
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.
 
M

Marshall Barton

Steve said:
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.
 

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