Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Programmatically Referencing a Report

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sherwood - 04 Jan 2006 20:39 GMT
Greetings,

I have a very "novice" question in regards to reports.  I am trying to hide
several labels on a report base upon choices on the data entry form.  The
current code I have is below:

If Me.ChecHomeImp.Value = 1 Then
       [rptSurveyResults].lblHomeImprovementLoans.Visible = True
Else
       [rptSurveyResults].lblBuyingaVacationHome.Visible = False
End If

However, when I run this code I receive an error stating that it can't find
the field, "|" indicated in my expression.  Am I not referencing the report
properly?
Signature

Thanks in advance!

Sherwood

Roger Carlson - 04 Jan 2006 21:03 GMT
You are not referencing the report correctly.  Either of these should work:
        Reports![rptSurveyResults].lblHomeImprovementLoans.Visible = True
or
        Me.lblHomeImprovementLoans.Visible = True

Signature

--Roger Carlson
 Access Database Samples: www.rogersaccesslibrary.com
 Want answers to your Access questions in your Email?
 Free subscription:
 http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

> Greetings,
>
[quoted text clipped - 11 lines]
> the field, "|" indicated in my expression.  Am I not referencing the report
> properly?
Sherwood - 04 Jan 2006 22:37 GMT
I used the code below (with no errors), but it is still not displaying the
label on the
report if the approrpriate checkbox on the form has been checked.  Is it not
possible to set the visible property of a label (on a report) at run time?  
My goal is to have the report only display the labels that pertain to
checkboxes (that have been checked) on the main form.  Am I approaching this
wrong?

[Note:  I am running the code below from the "Click" event of a button on
the Data Entry form].

If Me.ChecHomeImp.Value = -1 Then
       Reports![rptSurveyResults].lblHomeImprovementLoans.Visible = True
Else
       Reports![rptSurveyResults].lblHomeImprovementLoans.Visible = False
End If

Signature

Thanks!

Sherwood

> You are not referencing the report correctly.  Either of these should work:
>          Reports![rptSurveyResults].lblHomeImprovementLoans.Visible = True
[quoted text clipped - 19 lines]
> report
> > properly?
Marshall Barton - 04 Jan 2006 22:49 GMT
>I have a very "novice" question in regards to reports.  I am trying to hide
>several labels on a report base upon choices on the data entry form.  The
[quoted text clipped - 9 lines]
>the field, "|" indicated in my expression.  Am I not referencing the report
>properly?

You can not reliably manipulate a report from outside the
report because the form is not synchronized with the report
opening and displaying.

This kind of thing should be done in the report, probably in
its Open event:

If Forms!yourform.ChecHomeImp = 1 Then
    Me.lblHomeImprovementLoans.Visible = True
Else
    Me.lblBuyingaVacationHome.Visible = False
End If

Signature

Marsh
MVP [MS Access]

Sherwood - 05 Jan 2006 17:01 GMT
I have tried the syntax you mentioned (in the "Open" event of the report),
but it is not working.  I am not receiving an error, it just isn't making the
label visible on the report if the checkbox is selected on the form.  Also,
as I typed in the line of code below, "Visible" is not one of the listed
properties that displays (even though I have Auto List Members checked under
"Tools, Options, Editor").  Any ideas?  [Note:  I have to use "-1" to see if
a checkbox has been selected instead of "1"].

Private Sub Report_Open(Cancel As Integer)
If Forms![frmMainSurvey].ChecHomeImp.Value = -1 Then
   Me.lblHomeImprovementLoans.Visible = True
Else
   Reports![rptSurveyResults].lblHomeImprovementLoans.Visible = False
        Me.lblHomeImprovementLoans.Visible = False
End If
Signature

Thanks!

Sherwood

> >I have a very "novice" question in regards to reports.  I am trying to hide
> >several labels on a report base upon choices on the data entry form.  The
[quoted text clipped - 22 lines]
>     Me.lblBuyingaVacationHome.Visible = False
> End If
Roger Carlson - 05 Jan 2006 17:07 GMT
Try it in the On Format event of the Detail Section.

Signature

--Roger Carlson
 Access Database Samples: www.rogersaccesslibrary.com
 Want answers to your Access questions in your Email?
 Free subscription:
 http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

> I have tried the syntax you mentioned (in the "Open" event of the report),
> but it is not working.  I am not receiving an error, it just isn't making the
[quoted text clipped - 38 lines]
> > Me.lblBuyingaVacationHome.Visible = False
> > End If
Marshall Barton - 05 Jan 2006 20:42 GMT
>I have tried the syntax you mentioned (in the "Open" event of the report),
>but it is not working.  I am not receiving an error, it just isn't making the
[quoted text clipped - 11 lines]
>         Me.lblHomeImprovementLoans.Visible = False
>End If

I don't see how that can happen when the form checkbox is
checked unless there is something else wrong.  Although I
would expect some kind of error if these are not right, make
sure the form is still open and that the names of everything
are spelled correctly.

It looks like you have an extra line in the Else situation
or maybe you're just using the long reference???  This line
is not wrong, but would normally be written:

    Me.lblHomeImprovementLoans.Visible = False

Signature

Marsh
MVP [MS Access]

John Luquer - 06 Jan 2006 17:38 GMT
Try this:

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

If Me.ChecHomeImp= yes Then
   Me.lblHomeImprovementLoans.Visible = True    
Else
   Me.lblHomeImprovementLoans.Visible = False

you may need to change yes to -1 since its a text box.

> I have tried the syntax you mentioned (in the "Open" event of the report),
> but it is not working.  I am not receiving an error, it just isn't making the
[quoted text clipped - 38 lines]
> >     Me.lblBuyingaVacationHome.Visible = False
> > End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.