Hide report footer based on report's data ? (1 Viewer)

smig

Registered User.
Local time
Today, 06:55
Joined
Nov 25, 2009
Messages
2,209
how do I hide the report footer based on the report's data ?
I'm trying to hide if number of users = 1

The report's data is a query built inside the report's RecordSource, not a self standing query.

Thanks,
Tal
 

Mihail

Registered User.
Local time
Today, 06:55
Joined
Jan 22, 2011
Messages
2,373
I think that is not possible, but I can see two workarounds:
1) Create a duplicate report, remove the footer and show THIS report if the number of users = 1;
2) Hide the controls in the footer if the number of users = 1.
Me.ControlName.Visible = (NumberOfUsers > 1)
 

smig

Registered User.
Local time
Today, 06:55
Joined
Nov 25, 2009
Messages
2,209
Problem is seems I cant reference the number of users data.
Can not reference it even if I put it as a text box on the form.
 

essaytee

Need a good one-liner.
Local time
Today, 13:55
Joined
Oct 20, 2008
Messages
512
how do I hide the report footer based on the report's data ?
I'm trying to hide if number of users = 1

The report's data is a query built inside the report's RecordSource, not a self standing query.

Thanks,
Tal

I'm using Access 2010 on a 2003 database, picked a report and tested the following on the Page Footer.

Code:
Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)
    If 1 = 1 Then
        Cancel = True
    End If
End Sub

This cancelled out my Page Footer section. Obviously, pick the ReportFooter_Format event and replace the 1 = 1 expression.
 

Mihail

Registered User.
Local time
Today, 06:55
Joined
Jan 22, 2011
Messages
2,373
Problem is seems I cant reference the number of users data.
Can not reference it even if I put it as a text box on the form.
Not sure what you say.
Should be a simple DCount function.
 

smig

Registered User.
Local time
Today, 06:55
Joined
Nov 25, 2009
Messages
2,209
Not sure what you say.
Should be a simple DCount function.
Dcount() cant be used as I dont have a built query to work with.
I could build one but dont want another query in my collection just for this.
 

smig

Registered User.
Local time
Today, 06:55
Joined
Nov 25, 2009
Messages
2,209
DCount has it's own query, so no need to design a new one.
http://www.techonthenet.com/access/functions/domain/dcount.php
Dcount's domain must be a table or a query. It won't work with a query string.
Something like this won't work:
Code:
dim strQuery as string
strQuery  = me.RecordSource
Dcount("[UsersID]", strQuery)
As said before I have no built query for my report. The query is built in the report's RecordSource.

As the report footer is narrow I will hide the data in it using Conditional Format to paint the text in white.
The result will be just a narrow empty space. not a big issue.
 

smig

Registered User.
Local time
Today, 06:55
Joined
Nov 25, 2009
Messages
2,209
After a lot of tests I found where the problem is.
There is no way to check any form's data or values in it's OnOpen event. The form still has no data in it at this time.
An external data test (Like DCount) will work.
 

essaytee

Need a good one-liner.
Local time
Today, 13:55
Joined
Oct 20, 2008
Messages
512
After a lot of tests I found where the problem is.
There is no way to check any form's data or values in it's OnOpen event. The form still has no data in it at this time.
An external data test (Like DCount) will work.

I'm not understanding your issue. The event to turn on or off the report footer is the ReportFooter_Format event:

Code:
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    Dim intCount As Integer
    intCount = DCount("Contact_ID", "tbl_Contact")
    If intCount < 241 Then
        Cancel = True
    End If
End Sub

[I]' Note: the above works for me.   Could have created a temporary SQL statement and acheive the same result.
' For the particular report in question, Contact_ID has nothing to do with the report.
[/I]

I know you have mentioned in an earlier post you don't want to create another query just for this, but why not? If you don't want to, or can't use the DCount function, simply create a query on the fly, execute it, check it's value, do your if/then check to determine whether the footer should be printed or not. This is all done from within the ReportFooter_Format event.
 

smig

Registered User.
Local time
Today, 06:55
Joined
Nov 25, 2009
Messages
2,209
Funny enough it will work as I wanted if I put the code in the OnFormat event (Data already exist on form)
I never expected I could hide a section in it's OnFormat event. It make no sense to me, but I'm glad it work :)
 

Users who are viewing this thread

Top Bottom