Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-15-2019, 05:59 AM   #1
Punice
Newly Registered User
 
Join Date: May 2010
Location: Middletown, VA
Posts: 103
Thanks: 46
Thanked 1 Time in 1 Post
Punice is on a distinguished road
Reports displays more than selected records

My Access 2007 table holds 25 groups of trip records. The individual group records are sequentially numbered trip leg record sets, such as: 1.01, 1.02. . .etc. for the for as many legs for the first group, 2.01, 202...etc. for the second group and so on for all 25 groups.

Objective: Select any number from 1 to 25, from a combobox control's list, on a form, and open a report that displays all of the leg's records for that number (ie., trip).

Problem: When I select 1, for example, the report displays records (grouped) for 1, 10 thru 19 and when I pick 2, the report displays records for 2, 20 thru 25. However, when I pick 2 thru 9,
the reports display correctly. I want to be able to display on the records associated with the number that I pick.

Question: What additional code is required to facilitate what I want to happen in my routine shown below?
-----
Private Sub cboTrips_lbl_AfterUpdate()
Dim strReport As String
Dim lngView As Long

strReport = "rptTrips_By_TN" 'names the report to display
T_TN = [Forms]![frmReport_Selector]![cboTrips_lbl] 'gets the trip number

'Close the report if already open: otherwise it won't filter properly.
If CurrentProject.AllReports(strReport).IsLoaded Then
DoCmd.Close acReport, strReport
End If

lngView = acViewPreview 'Use acViewNormal to print instead of preview.

'Open the report to display the selected trip group using DBGuy's code
DoCmd.OpenReport strReport, acViewPreview, , "[T_TN] Like '" & Me.cboTrips_lbl & "*'"
End Sub

Punice is offline   Reply With Quote
Old 10-15-2019, 06:16 AM   #2
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,569
Thanks: 68
Thanked 2,745 Times in 2,630 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Reports displays more than selected records

do you need Exact match for the cboTrips?
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 10-15-2019, 07:03 AM   #3
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,912
Thanks: 57
Thanked 1,293 Times in 1,274 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Reports displays more than selected records

Hi. I think Arnel is right. Use the equal sign instead of Like and take out the wildcard.
Code:
'Open the report to display the selected trip group using DBGuy's code
 DoCmd.OpenReport strReport, acViewPreview, , "[T_TN] = '" & Me.cboTrips_lbl & "'"

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 10-15-2019, 08:40 AM   #4
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,569
Thanks: 68
Thanked 2,745 Times in 2,630 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Reports displays more than selected records

if not Exact match, try this:

Open the report to display the selected trip group
DoCmd.OpenReport strReport, acViewPreview, , "[T_TN] Between '" & Me.cboTrips_lbl & "' And '" & Me.cboTrips_lbl & ".99'"
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 10-16-2019, 09:26 AM   #5
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,271
Thanks: 15
Thanked 1,594 Times in 1,514 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: Reports displays more than selected records

If your field is actually stored as "1.01", that will make it more difficult to work with. NEVER mush two values into a single field. You should have two numeric fields rather than a single text field.

__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Reply

Tags
code , docmd , openreport , report

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
listbox vba displays non selected items anissaw Modules & VBA 4 06-11-2018 06:33 PM
Memo text displays as Chinese in Reports JT1 Reports 1 06-25-2014 01:38 AM
Reports displays all records...I don't want it to Kill_Switch Reports 2 03-26-2010 06:13 PM
[SOLVED] conditional displays in printed reports accessdumbell Reports 1 02-17-2006 05:02 PM
[SOLVED] conditional displays in printed reports accessdumbell Reports 0 02-16-2006 12:31 PM




All times are GMT -8. The time now is 09:35 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World