A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Opening a Report to a Specific Record



 
 
Thread Tools Display Modes
  #1  
Old July 30th, 2009, 12:50 AM posted to microsoft.public.access.reports
PennyB
external usenet poster
 
Posts: 6
Default 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  
Old July 30th, 2009, 01:05 AM posted to microsoft.public.access.reports
JD
external usenet poster
 
Posts: 199
Default 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  
Old July 30th, 2009, 01:13 AM posted to microsoft.public.access.reports
fredg
external usenet poster
 
Posts: 4,386
Default 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  
Old July 30th, 2009, 01:16 AM posted to microsoft.public.access.reports
PennyB
external usenet poster
 
Posts: 6
Default 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  
Old July 30th, 2009, 01:20 AM posted to microsoft.public.access.reports
PennyB
external usenet poster
 
Posts: 6
Default 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  
Old July 30th, 2009, 05:06 PM posted to microsoft.public.access.reports
Larry
external usenet poster
 
Posts: 464
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.