Don't Want Field on Report to Appear if ___ is True

raeba

Registered User.
Local time
Today, 06:31
Joined
May 25, 2005
Messages
12
Hi,

I hope that I am posting in the proper place. I am new here, and a newbie to all of this, so please be gentle and simple (and I have no reason to believe that you woudn't ;) ).

I have an old sample database that I have been using in Access 1997. It is the "Order Entry" database that came stock in 1997.

However, I have added some checkboxes on the main form and some fields on the invoices...

What I'd like to do is make a few fields on the invoice report not show (print on the paper) when a certain checkbox is checked (true) on the "Orders by Customers" form.

So, I'd suspect that I'd need to say something like..."if this box is checked, then don't show this and that field" - so that they don't print. [psuedo code...of course]

If you could please tell me what and where to type this information in to the code, I would appreciate it. I don't have a clue... I have only needed this one thing done in all these years of using the DB, so it's unlikely that I'll go to school to learn this one things (as very interesting as it is).

I'd sincerely appreciate you helping me out...

Thank you so much.

Warm Regards,

Raeba
 
I am going to use a step above "psuedo code" I will use "Crap Code".
but I think this is the general idea (I'm pretty new, I just thought I'd try here and learn).

I think for you could tie this to an "on open" event in your report.

Private sub HideMe()
if forms!myform.myfield = true then
forms!myform.myfield.visible = false
end if

It's a start anyway.
 
I've typed the following into the "Report_Invoice" (General) code area:

Code:
Private Sub HideMe()
    If Forms!Command44.Seeds = True Then
        Forms!Report_Invoice.Label65.Visible = False
    End If
End Sub

It did not work. I am not sure how to find the names of the forms...objects...etc, but I think I have them correct.

I did not get any errors with this -- it just didn't work.

raeba
 
I also tried the following in the open event for the Report_Invoice, and it didn't work.

Code:
Private Sub HideMe()
    If Forms![Orders by Customer].Seeds = True Then
        Report_Invoice.Label65.Visible = False
    End If
End Sub

I'm sure this is extremely easy, but I don't have any familiarity with it. So, I am just looking at other text in the code, and trying to be somewhat logical, but I am missing it somewhere.

Your help is appreciated.

Raeba
 
I'm just giving a guess as to what your actual object names are but maybe you can better correct your syntax by seeing this:

Code:
Private Sub HideMe()
    If Forms![COLOR=Red]FormName[/COLOR]!Command44.Seeds = True Then
      [COLOR=Red] Reports[/COLOR]!Report_Invoice!Label65.Visible = False
    End If
End Sub
 
If you have spaces:

Forms![Form Name]![Command Name]


Example:
Forms![Main Form]![Label 32].Value
 
modest said:
If you have spaces:
Forms![Form Name]![Command Name]
Example:
Forms![Main Form]![Label 32].Value

It appears that the form name is Orders by Customer, because the project window says that if is Form_Orders by Customer, and there is a checkbox on that form that for which the name and control source is Seeds. The report name shown in the project window is Report_Invoice. And, there is a text box on that report named Label65 that I do not want to show if the checkbox is checked (true) on the Orders by Customer form.

Here is the latest code that I tried that did not work:

Code:
Private Sub HideMe()
    If Forms![Orders by Customer].Seeds = True Then
       Reports!Invoice!Label65.Visible = False
    End If
End Sub

What am I doing wrong? What should the code state, and where should I put it? How do I navigate to the correct code entry point?

Thank you very much. It seems like this is narrowing down. I imagine that someone here is going to be able to nail this now. I hope so.

Thank you so much.

Raeba
 
The code needs to be in the report, I think the OnFormat is the event you need. Try:-

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Forms![Orders by Customer].Seeds = True Then
Me.Label65.Visible = False
End If
End Sub


Peter
 
Bat17 said:
The code needs to be in the report, I think the OnFormat is the event you need. Try:-

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Forms![Orders by Customer].Seeds = True Then
Me.Label65.Visible = False
End If
End Sub


Peter

It looks like that did it. It's late here, so I will look at in better after some sleep. However, it does look like that did it for me.

Thank you very, very much!

raeba
:D
 
Ok, yes, that did it.

Here's what I have now:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If Forms![Orders by Customer].Seeds = True Then
        Me.Label65.Visible = False
        Me.[Company Name].Visible = False
        Me.CompanyAddress.Visible = False
        Me.CompanyAddress2.Visible = False
        Me.CompanyCountry.Visible = False
        Me.CompanyPhoneFax.Visible = False
    End If
End Sub

If that box is checked, then I don't show any of those fields.

What if I want to just change the values of those fields, rather than disable them, what would I use?

I tried using .Text = "la la la" instead of .Visible = false, but I got an error that the control needed focus. However, when I used Me.[Company Name].SetFocus, I got another error that I couldn't use that code there.

Any ideas?
 
typing on the run :0
try with out a qualifier

Me.CompanyPhoneFax = "some text"

another thought is that you may need to do this in the Format event


Peter
 
Bat17 said:
typing on the run :0
try with out a qualifier

Me.CompanyPhoneFax = "some text"

another thought is that you may need to do this in the Format event


Peter

I have it all in the format event. When I enter it without the qualifier as you suggested, I get the "object doesn't support this property or method" still.
 
I think I see it now, In a report you wont be able to change the value of a bound field as it can repeat and Access either would not know which repeat to change or would have to change them all. However you can change the value of an Unbound textbox.
So a work around may be to hide the "CompanyPhoneFax " box and create a new unbound one. Then you could use code like

If Me![CompanyPhoneFax ]<>"" Then
Me![FakeCompanyPhoneFax ] = Me![CompanyPhoneFax ]
Else
Me![FakeCompanyPhoneFax ] = "No Fax"

End If


HTH

Peter
 
Bat17 said:
I think I see it now, In a report you wont be able to change the value of a bound field as it can repeat and Access either would not know which repeat to change or would have to change them all. However you can change the value of an Unbound textbox.
So a work around may be to hide the "CompanyPhoneFax " box and create a new unbound one. Then you could use code like

If Me![CompanyPhoneFax ]<>"" Then
Me![FakeCompanyPhoneFax ] = Me![CompanyPhoneFax ]
Else
Me![FakeCompanyPhoneFax ] = "No Fax"

End If


HTH

Peter

Ok, I'll give it a try. Also, I wonder about one of those fields (Label5) was just a text box on the report, not one of the fields that gets the info elsewhere like the company stuff. I got that one to change with Me!Label65.Caption = "la la la"

raeba
 
Yep, labels will change OK because they would have the same value everytime they are used. If you are printing something like an invoice where you just get a single page it is not so obvious but if you are printing a monthly report with lots of grouping then you can see that the same lable may be used several times with the same value but the associated text field would have differnt values each time.

Peter
 

Users who are viewing this thread

Back
Top Bottom