Windows XP
Microsoft Access 2000 (9.0.3821 SR-1)
Working with ms-access I have created a form to place Purchase Orders. I have also create the report to print the Purchase Order. In the Orders form I created a command button that calls the report "Order Document" and it work
almost fine. The problem is that it brings up the report with the FIRST order created an I want it to bring the Order that has just been created. Here is the code used:
Private Sub PreviewInvoice_Click()
Dim LinkFilter As String
On Error GoTo Err_PreviewInvoice_Click
If Forms![Orders]![Order Details Subform].Form.RecordsetClone.RecordCount = 0 Then
MsgBox "Enter order information before previewing order."
Else
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport "Order Document", acPreview, , "Me![Orders]![OrderID]"
End If
Exit_PreviewInvoice_Click:
Exit Sub
Err_PreviewInvoice_Click:
If Err <> 2501 Then
MsgBox Err.Description
End If
Resume Exit_PreviewInvoice_Click
End Sub
I would appreciate it if the answer includes the sample or corrected code.
Thanks in advance.
Microsoft Access 2000 (9.0.3821 SR-1)
Working with ms-access I have created a form to place Purchase Orders. I have also create the report to print the Purchase Order. In the Orders form I created a command button that calls the report "Order Document" and it work
almost fine. The problem is that it brings up the report with the FIRST order created an I want it to bring the Order that has just been created. Here is the code used:
Private Sub PreviewInvoice_Click()
Dim LinkFilter As String
On Error GoTo Err_PreviewInvoice_Click
If Forms![Orders]![Order Details Subform].Form.RecordsetClone.RecordCount = 0 Then
MsgBox "Enter order information before previewing order."
Else
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport "Order Document", acPreview, , "Me![Orders]![OrderID]"
End If
Exit_PreviewInvoice_Click:
Exit Sub
Err_PreviewInvoice_Click:
If Err <> 2501 Then
MsgBox Err.Description
End If
Resume Exit_PreviewInvoice_Click
End Sub
I would appreciate it if the answer includes the sample or corrected code.
Thanks in advance.