Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Reports

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 01-26-2009, 08:05 AM
Novice
 
Join Date: Jan 2009
Posts: 4
Dr Do is on a distinguished road
Exclamation Display Query Parameter In Report With No Data

I have a daily report which needs to be run and saved even if there is are no records returned from the query. Originally I formatted the header to display the report name plus the user entered paramater in the underlaying query however if the query returns no records it will not pass the paramater to the report. How can I force the query to pass the paramater entered? I know most people don't require a report with no records but in this case even no records is important to archive.
Thank you.
Reply With Quote
  #2  
Old 02-11-2009, 06:18 PM
Novice
 
Join Date: Feb 2009
Posts: 16
ibgreat is on a distinguished road
Default

If it is just a report that you are running couldn't you just put the results into a recordset (or maybe a temporary table) and use something like

Me.Yourtextbox.DefaultValue = "No Records Returned."
If rs.BOF=rs.EOF then
Me.Yourtextbox.Visible = True
End If

I don't recall the exact sytax, but you should get the idea. I don't think you could do this directly on the query results, thus the recordset or table suggestion. If you used a temporary table you would need to use DFirst and DLast. Obviously, the OnOpen Event should be set to Me.Yourtextbox.Visible = False
Reply With Quote
  #3  
Old 02-12-2009, 10:50 AM
Novice
 
Join Date: Jan 2009
Posts: 4
Dr Do is on a distinguished road
Default

Thank you for the reply. Unfortunately that is a bit beyond my skills. To clarify do you mean create a temporary table and base the report on the table? If so how would I force the parameters entered in the query into the temp table so the report would pick it up?
Reply With Quote
  #4  
Old 02-12-2009, 02:24 PM
Novice
 
Join Date: Feb 2009
Posts: 16
ibgreat is on a distinguished road
Default

Okay, even easier...

Why don't you use the DLast function and test for null. If Null then your control would display that there are no records via the control source.

If your control was a list box for example it might look like this.

Quote:
If Not IsNull(DLast(Me.lstDisplayQryResults)) Then
Me!lstDisplayQryResults.RowSourceType = "Value List"
Me!lstDisplayQryResults.RowSource = " No Records to Display" 'I don't know how column you have but you look up the value list syntax and add commas as needed.
End If
This piece of code should probably go in the OnOpen event for your form. In the OnClose event you would have to reset your list box.

Quote:
Me!lstDisplayQryResults.RowSourceType = "Table/Query"
As always I recommend checking my syntax as it is really perfect.
Reply With Quote
  #5  
Old 02-16-2009, 11:45 AM
Novice
 
Join Date: Jan 2009
Posts: 4
Dr Do is on a distinguished road
Default

Thank you. The only problem is not just to show there are no records but to carry through the paramater entered. No records is as important as records returned. For example there was a text box which contained the text and the query parameter to run the report so it would display "Check In for [date entered]" or "Check In 02/09/09"

The problem is when the query returns no records, it does not pass the parameter entered to the report so the title just contains an error. I need to title to contain the paramater the user entered regardless of whether the query returns any records. Is there a way to do this without extensive code?

Thanks in advance.
Reply With Quote
  #6  
Old 02-16-2009, 07:42 PM
Novice
 
Join Date: Feb 2009
Posts: 16
ibgreat is on a distinguished road
Default

Quote:
As always I recommend checking my syntax as it is really perfect.
This is funny, my grammar can be pretty poor as well. This should have said "rarely perfect".

Quote:
The problem is when the query returns no records, it does not pass the parameter entered to the report so the title just contains an error. I need to title to contain the paramater the user entered regardless of whether the query returns any records. Is there a way to do this without extensive code?
I am not clear on this. I assume that the date entered field is being pulled directly from the forms text box where the date is entered. Your query shouldn't have anything to do with this????

If you wanted to put this in the code I provided change:
Code:
 
Me!lstDisplayQryResults.RowSource = " No Records to Display"
To....
Code:
Me!lstDisplayQryResults.RowSource = " No Records to Display for " & Me.YourDateTextBoxName
Reply With Quote
  #7  
Old 02-20-2009, 08:50 AM
Novice
 
Join Date: Jan 2009
Posts: 4
Dr Do is on a distinguished road
Default

I am using a simple report based on a select query which prompts the user for the parameter prior to each run. It is the paramater the user inputs that I need to display on the report even when the report contains no matching records. Are you suggesting using a text box to initiate the query rather than allowing the native prompt? Thank you
Reply With Quote
Reply

Bookmarks

Tags
report

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
calculate difference of $$ than can display in the subtotals in a report taniuca Queries 0 08-07-2008 05:02 PM
How to display data from another record rodrigo Access 1 07-24-2006 05:29 PM
How to Display parameter values on the report fadone Reports 4 01-04-2006 11:36 PM
Add combo box to parameter query louisa14 Queries 1 12-10-2005 05:38 AM
DISPLAY INPUT PARAMETERS ON THE REPORT fadone Forms 1 12-09-2005 07:26 PM


All times are GMT -8. The time now is 02:54 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.