If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Preview doesn't open current record
I have the basic details of our invoices (which are reports) displayed on a
continuous form i.e. date, number, customer, amount. At the end of each row I have a button so that we can open the form on which the invoice was created, to modify it. That works fine, it opens the selected invoice. I also have a button that should open a preview of the selected invoice (rpt). However, I can't get this to fire the correct record - it insists on opening the last (most recently created) invoice, no matter on which line the record selector may be. This is the code I am using on the Click event of that button: Private Sub cmdPreviewInvoice_Click() On Error GoTo Err_cmdPreviewInvoice_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "rptInvoicePrint" stLinkCriteria = "[InvNo]=" & Me![InvNo] DoCmd.OpenReport stDocName, , , stLinkCriteria, acPreview Exit_cmdPreviewInvoice_Click: Exit Sub Err_cmdPreviewInvoice_Click: MsgBox Err.Description Resume Exit_cmdPreviewInvoice_Click End Sub Where am I going wrong?? Thanks a lot CW |
#2
|
|||
|
|||
Preview doesn't open current record
On Wed, 30 Jan 2008 11:55:01 -0800, CW wrote:
I have the basic details of our invoices (which are reports) displayed on a continuous form i.e. date, number, customer, amount. At the end of each row I have a button so that we can open the form on which the invoice was created, to modify it. That works fine, it opens the selected invoice. I also have a button that should open a preview of the selected invoice (rpt). However, I can't get this to fire the correct record - it insists on opening the last (most recently created) invoice, no matter on which line the record selector may be. This is the code I am using on the Click event of that button: Private Sub cmdPreviewInvoice_Click() On Error GoTo Err_cmdPreviewInvoice_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "rptInvoicePrint" stLinkCriteria = "[InvNo]=" & Me![InvNo] DoCmd.OpenReport stDocName, , , stLinkCriteria, acPreview Exit_cmdPreviewInvoice_Click: Exit Sub Err_cmdPreviewInvoice_Click: MsgBox Err.Description Resume Exit_cmdPreviewInvoice_Click End Sub Where am I going wrong?? Thanks a lot CW I see 2 errors. 1) Access doesn't save new data unless you navigate to another record, close the form, or explicitly tell it to save the data. Add one line of code to your existing code (Marked with '*** below): Private Sub cmdPreviewInvoice_Click() On Error GoTo Err_cmdPreviewInvoice_Click DoCmd.RunCommand acCmdSaveRecord '*** Dim stDocName As String Dim stLinkCriteria As String stDocName = "rptInvoicePrint" stLinkCriteria = "[InvNo]=" & Me![InvNo] etc..... See #2 below 2) Also Note that your OpenReport syntax is not correct. You have... DoCmd.OpenReport stDocName, , , stLinkCriteria, acPreview It should be.... DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria etc........ -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#3
|
|||
|
|||
Preview doesn't open current record
I'm always happy to get an answer from you Fred, cos I know it's always going
to work - thanks a lot CW "fredg" wrote: On Wed, 30 Jan 2008 11:55:01 -0800, CW wrote: I have the basic details of our invoices (which are reports) displayed on a continuous form i.e. date, number, customer, amount. At the end of each row I have a button so that we can open the form on which the invoice was created, to modify it. That works fine, it opens the selected invoice. I also have a button that should open a preview of the selected invoice (rpt). However, I can't get this to fire the correct record - it insists on opening the last (most recently created) invoice, no matter on which line the record selector may be. This is the code I am using on the Click event of that button: Private Sub cmdPreviewInvoice_Click() On Error GoTo Err_cmdPreviewInvoice_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "rptInvoicePrint" stLinkCriteria = "[InvNo]=" & Me![InvNo] DoCmd.OpenReport stDocName, , , stLinkCriteria, acPreview Exit_cmdPreviewInvoice_Click: Exit Sub Err_cmdPreviewInvoice_Click: MsgBox Err.Description Resume Exit_cmdPreviewInvoice_Click End Sub Where am I going wrong?? Thanks a lot CW I see 2 errors. 1) Access doesn't save new data unless you navigate to another record, close the form, or explicitly tell it to save the data. Add one line of code to your existing code (Marked with '*** below): Private Sub cmdPreviewInvoice_Click() On Error GoTo Err_cmdPreviewInvoice_Click DoCmd.RunCommand acCmdSaveRecord '*** Dim stDocName As String Dim stLinkCriteria As String stDocName = "rptInvoicePrint" stLinkCriteria = "[InvNo]=" & Me![InvNo] etc..... See #2 below 2) Also Note that your OpenReport syntax is not correct. You have... DoCmd.OpenReport stDocName, , , stLinkCriteria, acPreview It should be.... DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria etc........ -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
Thread Tools | |
Display Modes | |
|
|