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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding Fields 1

Status
Not open for further replies.

Tamrak

MIS
Jan 18, 2001
213
US
In the present, we have to use two reports, which come from the same source (table) because one field controls it. This is the scenario

Field name = USA; Value = "Yes" or "No"

Let's say the table has many fields, A, B, C, D, E, F, G, H, I, J and USA.

Report1 consists of the following fields: A, B, C, D, E, G, H, J and USA. (no F and I)

Report2 consists of the folllowing fields; A, B, C, D, F, G, I, J and USA. (no E and H)

In the present, if the USA = "Yes", Report1 will be printed. Otherwise, Report2 will be printed.

The report looks very similar, except for the fields that I mentioned.

In order to create an efficiency, the management would like to combine them into one report. I am unsure whether I can hide the fields based on the condition. So, when the record states that USA = NO, field F will be replaced with Field E and Field I will be replaced with Field H.

The reason is, the management DOES NOT want a sorting order by Yes or No in the USA field. They would like just to print the record from the first in the table to the last.

I tried to use the code below and came up with an error. I would like to do just one field first.

Error message = Compile error: Method or data member not found.

I put the code in the Details line.

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

Me.txtE.Visible = (Me.txtUSA="Yes")
Me.txtF.Visible = (Me.txtUSA="No")

'Try to experiment with one field first.
'txtE, txtF, txtUSA are all bounded fields.

End Sub



What did I forget here?? If the code is incorrect, please correct it for me. Thanks.

 
I don't see anything that might be wrong. Does your code compile? If you begin typing Me.txt... do the control names appear in the intellisense? Are all the controls in the detail section?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I'll always put my money on Duane being right. I just don't understand the syntax of the coding. Does =(Me.txtUSA="Yes") evaluate to True / False? or 0 / 1?

I've found that in formatting controls on the Detail Format event, I have to specify the True and the False results I want.


Code:
If txtUSA = "Yes" Then
   [COLOR=green]'Report 1[/color]
txtF.Visible = False
txtI.Visible = False
txtE.Visible = True
txtH.Visible = True
Else
   [COLOR=green]'Report 2[/color]
txtF.Visible = True
txtI.Visible = True
txtE.Visible = False
txtH.Visible = False
End If


John




When Galileo theorized that Aristotle's view of the Universe contained errors, he was labeled a fool.
It wasn't until he proved it that he was called dangerous.
[wink]
 
Thank you all.

Solutions have been found based on what you have indicated.
 
I have another situation that is very similar to the last one.

Let's make it two fields to make the code to work.

Field K is "Currency" field;
Field L is "text" field.

The logic is ->

1. If K is blank, show me field L. If field L is blank, show me field K.

I received an error due to data type mismatch.

I plan to put something like this and it does not work.

Me.K.Visible = (Me.L Is Not Null)

I tried to replicate the format and it does not seem to

Me.K.Visible = (Me.L = "")

I do appreciate your suggestions. Thanks.


 
Try
Code:
Me.L.Visible = IsNull(Me.K)
Me.K.Visible = IsNull(Me.L)

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top