Hiding Labels in Reports

moagli

Registered User.
Local time
Today, 02:47
Joined
Nov 17, 2006
Messages
15
I have a report that contains a label with either 'scan' or 'no scan' written in it and i want the if statement
If Me.ScanL = "no Scan" Then
Me.ScanL.Visible = False
Else: Me.ScanL.Visible = True

to run in a report when it is loaded or is there another why or achieveing the same result so that when it loads and the label says no scan it does allow it to be shown?

Thanks in advance, if you need any more details just ask.
 
Put your code in the OnFormat event of the section with the label in it, probably the Detail section. Are you sure it is a label or could it be a TextBox?
 
Your are right it is a text box and i put that if statement in the detail format section as shown below but it doesnt seem to work:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.ScanL = "no Scan" Then
Me.ScanL.Visible = False
Else: Me.ScanL.Visible = True
End If
End Sub


Is there maybe something i'm missing, the reason it can't be deleted is beacuse there is a price corresponding to the 'scan' and so the total price malfunctions when it's entered as blank in the query.
 
Mixing single line and multi-line code is not a very good programming practice. Your code should read:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.ScanL = "no Scan" Then
   Me.ScanL.Visible = False
Else
   Me.ScanL.Visible = True
End If
End Sub
You are saying that the ScanL TextBox is visible on your report with no Scan showing, correct? Let's just turn it off as a test with:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.ScanL = "no Scan" Then
   Me.ScanL.Visible = False
Else
   Me.ScanL.Visible = [COLOR="Red"][B]False[/B][/COLOR]
End If
End Sub
It needs to be an exact match you know! It will not match to " no Scan" or "no Scan ".
 
Last edited:
Had the same sort of problem with reports - and I just tried all the combinations and as been pointed out needs to be exact - in the end
I had it tied to a yes/no option on my form and included it within my report if .= true then textbox.visble else etc

this works a charm - once you get your head round it and I have bits visible/invisble etc just by a tick box

g
 
Sorry just seen this other tread -- same type of thing
if me.xxxx = true then
textboxname.visible=false (or true ) depending on what you want it to do

I would recommend that you keep your trues and falses the same - so if x = true then show all the way throught he d/base
otherwise you have if x = true - then show and somewhere further down if x = true then false - you will lose the plot

basically keep the questions the same show it yes or no (not a mixture of)

Using a checkbox to disable/enable fields

--------------------------------------------------------------------------------

I want to enable/disable certain fields when a checkbox is ticked. I have put in the following coding in the "After Update" bit but it doesn't seem to work. Am I putting it in the wrong place or is just because my coding just really bad?

If Me.Member = True Then
Me.Member_ID.Enabled = True
Me.tbl_Appointment_First_Name.Enabled = False
Me.tbl_Appointment_Surname.Enabled = False
Me.tbl_Appointment_Contact_Number.Enabled = False
Else
Me.Member_ID.Enabled = False
Me.tbl_Customer_First_Name.Enabled = False
Me.tbl_Customer_Surname.Enabled = False
Me.tbl_Customer_Contact_Number.Enabled = False
Me.tbl_Appointment_First_Name.Enabled = True
Me.tbl_Appointment_Surname.Enabled = True
Me.tbl_Appointment_Contact_Number.Enabled = True
End If


Any help would be much appreciated, thanks!!
 
At the minute from a query ScanL text box is entered into a report but i want to have it so that when the report loads if it says 'No Scan' then its doesnt show that text box. I tried the second section of code and it turned the label off but then when i changed it to the first it didn't seem to work for some reason i have included a sample Database that you could have a look at?

Thanks for this help
 
In your database noscan is all one word , no spaces, then it works.
Why not test for scan and then if people get it wrong it will work with no scan or noscan

Brian

PS I guess RuralGuy was on the right track, did you not follow up his suggestion?
 
i got it to work now thanks and have used it for other text boxes on the form, just wondering is there any way i can reduce this amount of coding:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.ScanL = "Scan" Then
Me.ScanL.Visible = True
Else: Me.ScanL.Visible = False
End If
If Me.ScanP = "£50.00" Then
Me.ScanP.Visible = True
Else: Me.ScanP.Visible = False
End If
If Me.Procedure_notes <> "No Procedure" Then
Me.Procedure_notes.Visible = True
Else: Procedure_notes.Visible = False
End If
If Me.Procedure_notes <> "No Procedure" Then
Me.Procedure_price.Visible = True
Else: Procedure_price.Visible = False
End If
End Sub
 
You can reduce this bit

If Me.Procedure_notes <> "No Procedure" Then
Me.Procedure_notes.Visible = True
Me.Procedure_price.Visible = True
Else:
Procedure_notes.Visible = False
Procedure_price.Visible = False
End If

No point in checking the same thing twice.

Brian
 
thanks i've got it all sorted now its looking realli good!!
 

Users who are viewing this thread

Back
Top Bottom