Reports displays more than selected records (1 Viewer)

Punice

Registered User.
Local time
Today, 19:59
Joined
May 10, 2010
Messages
135
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 07:59
Joined
May 7, 2009
Messages
19,169
do you need Exact match for the cboTrips?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:59
Joined
Oct 29, 2018
Messages
21,358
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 & "'"
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 07:59
Joined
May 7, 2009
Messages
19,169
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'"
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 19:59
Joined
Feb 19, 2002
Messages
42,981
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.
 

Users who are viewing this thread

Top Bottom