report shows no data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I create a form and a button on the form. When I click the button, the code
would send information to the report to be printed out. However, data show up
on the report only when I debug line-by-line (there are no error at all. I
open connection to the database and recordsets). Otherwise, it prints out
blank pages.
Do you know why I have to trace line by line for the report to be printed
the data. If I don't do that, the report would print the blank page :=(. This
report has a dynamic record source, i.e., each time the program runs, the
program makes a query with new data. Thank you.
Here is some sample of code:
rsSample.AddNew
rsSample.Fields(0) = strID
rsSample.Fields(1) = rsS.Fields(2)
rsSample.Fields(2) = rsS.Fields(3)
rsSample.Update
rsSample.MoveNext

If rsSample.EOF Then
Exit Do
End If

Loop

DoCmd.OpenReport "rptSample", acViewNormal
 
Where is your code and what make you think it is going to display in a
report? Is the report bound to a record source?

You can place code in a report to open and loop through a recordset. Use the
Me.Print method to print values on the report.
 
I put the code in the module not in the report. I think it is going to
display in the report because the code I posted below loads data in
tblSample. And I made tblSample as a record source for the report. After
debuging, I check tblSample and see new data loaded in the table but when the
report is supposed to show data, it does not! Please help!!!
Thank you,
 
Is there anything that pauses opening the report until after tblSample has
been loaded?
 
No. As you can see the code below, right after the tblSample is loaded, I try
to OpenReport. It does open the report with header but no data at all. This
report has the record source is tblSample I already designed it. It is
driving me crazy!!!
Thank you for your help
 
I would add code that checks the number of records in the table prior to
opening the report.
Not sure if this will work but it might be worth a try. Swap your value in
for "x".
Do Until DCount("*","tblYourTable") > x
DoEvents
Loop
 
Thank you for your help. I did count and it appeared there are records in the
table. I don't know if a line of code that I write above these codes cause
the problem. This code just call a function to compare string and return the
result. This result will be assign to a field in the tblSample. But I dont'
think it is a problem.

Do you think should I add Refresh before or after tblSample is loaded? Also,
you do think should I add a report class module and using recordset to assign
tblSample as a record source for the report?? If so, can you show me how to
write the code?
Thank you very much for your help. tim
 
I would try lots of stuff until it worked.

Isn't tblSample already set as the record source in the saved report?
 
yes, tblSample is the record source. I don't know why it does not show up
data on the report.
It is very weird that I can't understand. I have to debug the code to get
the data printed out on the report. After closing the report, I try to open
the report again, this time data is gone, again.
 
I would place a break point in the code prior to opening the report and
check the table for records.

Also, you could try add a line of code prior to the report opening like:
MsgBox "You will next open the report", vbOKOnly + vbInformation, "Open
Report"
 
Hi again,
Here are the series of activities I do and find out the weird things...
1. Open tblSample to check data. Data are there.
2. Open the query that select all tblSample's fields. Data are there.
3. Open the report with the record source is the query at #2. Nothing is
there.
4. Click the button on the form to print out the report. Nothing is there on
the report.
(The purpose of this module is importing data from a txt file, load data
into tblSample with some manipulations, and print out the report. I have a
line of code to clear out the table before loading new data.)
5. Go back to click on the report tab and open the report itself -> Data
DOES show up!!!

It is driving me crazy! Pls help.
Would you like to take a look at my code pls provide me your email address
and I will send it to you. Sorry, I can not post it here.
Thanks, Tim
 
No. I don't have any code or macros in my report. I suspect maybe I use MS
Access 2002 while the database is for Access 2000, but I think that's
nonsense. Also, do you think should I try some code in the report's module to
force it show up data??
Thank you,
 
I would try run something like:

Msgbox "Record count tblSample: " & Dcount("*","tblSample")

both prior to opening the report and in the On Open event on the report.
 
Hi Duane:
Thank you very much for your time and effort. I appreciate your help. I
think I probably find out the problem. Here it is. I should use the REQUERY
function!!!
It seems work nicely.
Thank you again.
 
Back
Top