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
|
|||
|
|||
Opening a Report to a Specific Record
Can someone please tell me why this isn't working to open the Building Permit
(report) to one specific record? The report is based on a query that shows all records for Job Number and Permit Number. There is about 685 records. Here is the code I am using: Private Sub cmdBuildingPermit_Click() Dim strWhere As String strWhere = "[JobNumber] = " & Me.JobNumber & "" strWhere = "[PermitTaskNumber]=" & Me.PermitNumber & "" DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere End Sub What happens - I get a mess. I don't just get one record I get 495 and they are in random order. Thanks, PennyB |
#2
|
|||
|
|||
Opening a Report to a Specific Record
Penny, I am not an expert like most who answer these questions. But, why don't you try strWhere = "[JobNumber] = " & Me.JobNumber & " AND [PermitTaskNumber]=" & Me.PermitNumber "PennyB" wrote: Can someone please tell me why this isn't working to open the Building Permit (report) to one specific record? The report is based on a query that shows all records for Job Number and Permit Number. There is about 685 records. Here is the code I am using: Private Sub cmdBuildingPermit_Click() Dim strWhere As String strWhere = "[JobNumber] = " & Me.JobNumber & "" strWhere = "[PermitTaskNumber]=" & Me.PermitNumber & "" DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere End Sub What happens - I get a mess. I don't just get one record I get 495 and they are in random order. Thanks, PennyB |
#3
|
|||
|
|||
Opening a Report to a Specific Record
On Wed, 29 Jul 2009 16:50:01 -0700, PennyB wrote:
Can someone please tell me why this isn't working to open the Building Permit (report) to one specific record? The report is based on a query that shows all records for Job Number and Permit Number. There is about 685 records. Here is the code I am using: Private Sub cmdBuildingPermit_Click() Dim strWhere As String strWhere = "[JobNumber] = " & Me.JobNumber & "" strWhere = "[PermitTaskNumber]=" & Me.PermitNumber & "" DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere End Sub What happens - I get a mess. I don't just get one record I get 495 and they are in random order. Thanks, PennyB strWhere = "[JobNumber] = " & Me.JobNumber & " AND [PermitTaskNumber]=" & Me.PermitNumber DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere The above assumes both JobNumber and PermitTaskNumber are Number datatype fields. As far as the records being in random order, the above has nothing to do with the order of records in a report. To sort records in a report you should use the report's sorting and grouping dialog. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#4
|
|||
|
|||
Opening a Report to a Specific Record
Thanks, but that didn't work either.
"JD" wrote: Penny, I am not an expert like most who answer these questions. But, why don't you try strWhere = "[JobNumber] = " & Me.JobNumber & " AND [PermitTaskNumber]=" & Me.PermitNumber "PennyB" wrote: Can someone please tell me why this isn't working to open the Building Permit (report) to one specific record? The report is based on a query that shows all records for Job Number and Permit Number. There is about 685 records. Here is the code I am using: Private Sub cmdBuildingPermit_Click() Dim strWhere As String strWhere = "[JobNumber] = " & Me.JobNumber & "" strWhere = "[PermitTaskNumber]=" & Me.PermitNumber & "" DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere End Sub What happens - I get a mess. I don't just get one record I get 495 and they are in random order. Thanks, PennyB |
#5
|
|||
|
|||
Opening a Report to a Specific Record
They are both numbers. Also, I realize the sorting has nothing to do with
the code, but the funny thing is prior to putting the code in it was always in number order by Job Number. I use to have the query ask for the job number and permit number and that worked fine, but I want to make it easier on the end user. Thanks. "fredg" wrote: On Wed, 29 Jul 2009 16:50:01 -0700, PennyB wrote: Can someone please tell me why this isn't working to open the Building Permit (report) to one specific record? The report is based on a query that shows all records for Job Number and Permit Number. There is about 685 records. Here is the code I am using: Private Sub cmdBuildingPermit_Click() Dim strWhere As String strWhere = "[JobNumber] = " & Me.JobNumber & "" strWhere = "[PermitTaskNumber]=" & Me.PermitNumber & "" DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere End Sub What happens - I get a mess. I don't just get one record I get 495 and they are in random order. Thanks, PennyB strWhere = "[JobNumber] = " & Me.JobNumber & " AND [PermitTaskNumber]=" & Me.PermitNumber DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere The above assumes both JobNumber and PermitTaskNumber are Number datatype fields. As far as the records being in random order, the above has nothing to do with the order of records in a report. To sort records in a report you should use the report's sorting and grouping dialog. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#6
|
|||
|
|||
Opening a Report to a Specific Record
Hi PennyB,
I think you are missing some single quotes around in the double quote. strWhere = "[JobNumber] = ' " & Me.JobNumber & "'" strWhere = "[PermitTaskNumber]= ' " & Me.PermitNumber & "'" This is what I use in one of my codes: stWhere = "[InvoiceNo] ='" & Me.cmbInvoiceNumber.Column(0) & "'" Larry "PennyB" wrote: They are both numbers. Also, I realize the sorting has nothing to do with the code, but the funny thing is prior to putting the code in it was always in number order by Job Number. I use to have the query ask for the job number and permit number and that worked fine, but I want to make it easier on the end user. Thanks. "fredg" wrote: On Wed, 29 Jul 2009 16:50:01 -0700, PennyB wrote: Can someone please tell me why this isn't working to open the Building Permit (report) to one specific record? The report is based on a query that shows all records for Job Number and Permit Number. There is about 685 records. Here is the code I am using: Private Sub cmdBuildingPermit_Click() Dim strWhere As String strWhere = "[JobNumber] = " & Me.JobNumber & "" strWhere = "[PermitTaskNumber]=" & Me.PermitNumber & "" DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere End Sub What happens - I get a mess. I don't just get one record I get 495 and they are in random order. Thanks, PennyB strWhere = "[JobNumber] = " & Me.JobNumber & " AND [PermitTaskNumber]=" & Me.PermitNumber DoCmd.OpenReport "rptBuildingPermit", acViewPreview, , strWhere The above assumes both JobNumber and PermitTaskNumber are Number datatype fields. As far as the records being in random order, the above has nothing to do with the order of records in a report. To sort records in a report you should use the report's sorting and grouping dialog. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
Thread Tools | |
Display Modes | |
|
|