Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Not filling with data 1

Status
Not open for further replies.

funkmonsteruk

IS-IT--Management
Feb 8, 2002
210
GB
I've inherited a database which produces a report which is related to information which is added via a form which has a print button on it.

The report relates to a single record which will have most of it's details added by the user on this form.

The problem is that the report is failing to complete with data. I think the problem may be that the data being added to the form by the user is not being stored by the table prior to the report being printed (basically it seems as though the form is failing to refresh the data before printing the report).

The coding i'm using behind the print button is as follows

Private sub g2_click()
on error goto err_g2_click

dim stlinkcriteria as string
dim stdocname as string

stlinkcriteria = "[HistoryID]=" & Me![HistoryID]
stdocname = "Rpt_G2"
DoCmd.Openreport stdocname,, ,stLinkcriteria

Exit_g2_click:
exit sub
err_g2_click
msgbox Err.Description
Resume Exit_g2_click

End Sub


Can anyone suggest anything
 
You're probably right, the data hasn't been saved to the table yet. Try this:

Private sub g2_click()
on error goto err_g2_click

dim stlinkcriteria as string
dim stdocname as string

stlinkcriteria = "[HistoryID]=" & Me![HistoryID]
stdocname = "Rpt_G2"

Forms!YourFormName.Refresh

DoCmd.Openreport stdocname,, ,stLinkcriteria

Exit_g2_click:
exit sub
err_g2_click
msgbox Err.Description
Resume Exit_g2_click

End Sub


 
Thanks for the help Kosmo... Still seem to be having a problem though. The form with the data is called Frm_HistorySubform, which is a part of another form called Frm_History. I've tried the line
Forms!Frm_HistorySubform.Refresh
and it gives me an error saying database can't find form Frm_HistorySubform referred to in a macro expression or Visual Basic Code.
-The form you referenced may be closed or may not exist in this database.
-Database may have encountered a complile error in visual basic module of the form.

I've tried stepping through the code which gives no errors, but then again doesn't fill the report with data.

I tried using Forms!Frm_History.Refresh which doesn't give an error but then again isn't the form i want to refresh so doesn't fill the report with data.

Arrrgggghhhh why are these things never easy?
 
Oh, I didn't know a subform was involved.....Try something like this:
Code:
Forms!Frm_History.Frm_HistorySubform.Form.Refresh
 
Hi

Your assumption reference data not saving, is sound, try:

Private sub g2_click()
on error goto err_g2_click

dim stlinkcriteria as string
dim stdocname as string

If Me.Dirty Then
docmd.RunCommand acSaveRecord
End If

stlinkcriteria = "[HistoryID]=" & Me![HistoryID]
stdocname = "Rpt_G2"
DoCmd.Openreport stdocname,, ,stLinkcriteria

Exit_g2_click:
exit sub
err_g2_click
msgbox Err.Description
Resume Exit_g2_click

End Sub

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
This seems to be refreshing now Ken, but unfortunately the report is still not populating with data, any ideas as to what it might possibly be....?

Sorry this is all a bit vague, as i mentioned i've inherited this database from somebody else
 
Hi

OK, when you say 'the report is not populating' what is actually happening?, are you getting the NoData event firing?, if yes have you checked to ensure that at this point, the data IS actually in the table(s)?

If you are not getting the noData event firing, then it is finding record matching HistoryId, have you checked the recordsource etc of the controls on the report?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top