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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report isn't updated instantly?! 1

Status
Not open for further replies.

voyagergregory

Instructor
Aug 6, 2002
31
0
0
GB
Hi,

I have set-up a custom report, linked via a command button to a form.

Basically, the user fills in the form, and for any record that is currently displayed...they click on the report command button I have set-up and the custom report comes up JUST for the currently displayed record.

However, if I have just entered data and am still on that record, when I press the command button the report comes up blank.

However, if I go to another record or create another record, then come back to the record I want and try it again, it works fine.

I think it might be to do with the updating of data?

Please help,
Nathan
 
You have to save the record before you open the report. From memory which is foggy at times if you write a macro that first saves the record or in VBA DoCmd.SaveRecord then open the report using the where condition to get the right information on the report. I think that would do it. If you still have troubles I will recheck this post and see if I can help you more.

TTFN
 
I understand the logic of doing this.
Can you explain how I would do that step-by-step?
I'm not very good with coding or stuff.
My Preview Report link is on the form which displays one record at a time.
The code I used to do this was:

Private Sub cmdPrintRecord_Click()
Dim strReportName As String
Dim strCriteria As String

strReportName = "rptPrintRecordMachineOperator"
strCriteria = "[Clock Number]='" & Me![Clock Number] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub

Nath
 
Nath,

Try this:

Private Sub cmdPrintRecord_Click()
Dim strReportName As String
Dim strCriteria As String

strReportName = "rptPrintRecordMachineOperator"
strCriteria = "[Clock Number]='" & Me![Clock Number] & "'"
Forms!frmYourFormName.Refresh
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub



Forms!frmInqPatient.Refresh
 
I tried this and it didn't work.

When I tried to run it, it said somethin about needing something = after the form name and before the .refresh

the form name is "Machine Operator"

Please help,
Nath
 
I think that when I type

Forms!Machine Operator.refresh

Do I have to type Forms!frmMachine Operator.refresh?

I tried taht and it failed.
It said :
Compiled Error
Expected: =

Is it because ive used the word operator?

Please help
Nathan
 
Like ScriptMedic said, you have to save the record first.

**********************************************************
Private Sub cmdPrintRecord_Click()

Dim strReportName As String
Dim strCriteria As String

DoCmd.RunCommand acCmdSaveRecord

strReportName = "rptPrintRecordMachineOperator"
strCriteria = "[Clock Number]='" & Me![Clock Number] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub

**********************************************************

Dermot
 
The refresh will save the record.

If a field name contains spaces you must enclose it in brackets. Try:
Code:
Forms![Machine Operator].refresh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top