Help with the Access report

associates

Registered User.
Local time
Today, 11:01
Joined
Jan 5, 2006
Messages
94
Hi,

I was wondering if anyone might be able to help me here. In the report, when there is no data, the "error" comes out on every fields. My question is

For example in a table called student
studID FirstName LastName Address Course
1000 Michael Fox 34 Phillips st Science
1001
1002 Huge Gret 23 Pounted rd Science
1003 Benjamin Meyer 1 Canterbury rd Science

Assuming there is a form that has a listbox that shows a list of students information and a button for viewing their details. When user wants to see studID 1000, all he does is select the studID 1000 and click button "view". A report shows up with all the details of the 1000 student ID. It has no problem printing the result with studID: 1002 and 1003. But when he want to see the studID 1001, in the report,

studID: Error
FirstName: Error
LastName: Error
...

My question is if it's possible for me in the report to be able to know the linkcriteria so that i know that the user selected studID 1001. Because i have tried to figure out what the selected studID was but all i got is the "error" eventhough there is a value for studID in the case of 1001. Is this possible or something that is beyond our control? All I need to be able to work out is what studID is selected in the event of nodata.

I hope i can explain it well.
 
Actually there is an event for report called "NoData". That is where you use to trap for error. Write in code to display a messagebox saying no Data found and close the report.

HTH.
 
Try something like

Code:
Private Sub Report_NoData(Cancel As Integer)

    MsgBox "No Data found "
    Cancel = True

End Sub
 
how to read value from a form in a report

Thanks alot, Groundrush and Banana for your support.

Yep, i got it. But i have another tricky question here and wonder if you could help me here.

I'm not sure if this is a good practice type of coding. In the report, I have a code that's looking up the value in a form.

For example, I have a form called myform. In the form, i have a textbox called text1. Now, assuming text1 has a value of "Sam". Coming back to the report, in the section of detail, i added in an unbound textbox called TexttoText1. The value of this text depends on the value of text1 in the form.

In the report's detail,
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
me.TexttoText1.value = [Forms]![myform]!text1
End Sub

This doesn't work as i'm getting run-time error.

Any help would be appreciated.

Thank you in advance
 
I think this code should go in "On Format" event, not "Print" event.
 

Users who are viewing this thread

Back
Top Bottom