Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display three largest records in subform

Status
Not open for further replies.

Jayzxtx

Technical User
Joined
Oct 2, 2007
Messages
6
Location
US
I am trying to enter in a zip code in a combo box to show which service agents are the closest to the customers based on mileage. The mileage is used to calculate the travel cost which was done in a previous query. How would I filter my results to just show the three cheapest milage costs? Below is my code I have been working with. I have gotten the results to show in subform, but I am not sure what VB code I should use to filter the 3 cheapests cost.

Appreciate the help


Here is the code I have thus far

Private Sub command11_Click()
Me.Combo14.Value = Null


End Sub




Private Sub Detail_Click()
End Sub


Private Sub CalculateZip_Click()
Dim sqlString As String

If Not IsNull(Me.Combo14.Value) Then
sqlString = sqlString & " [Zodiaq Zip Locations_Zip] = " & Combo14.Value & " AND "
End If

If Len(sqlString) > 5 Then
sqlString = Left(sqlString, Len(sqlString) - 5)
Else
End If


Me.SA_Distance_Calc_subform6.Form.FilterOn = True
Me.SA_Distance_Calc_subform6.Form.Filter = sqlString
Me.SA_Distance_Calc_subform6.Form.Requery
Me.Refresh
' MasterForm.DoCmd.OpenQuery SQLCommand
On Error GoTo Err_CalculateZip_Click
' DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70

Exit_CalculateZip_Click:
Exit Sub

Err_CalculateZip_Click:
MsgBox Err.Description
Resume Exit_CalculateZip_Click


End Sub
 
try reposting in the Access VBA forum.
 
Or, try following the instructions given in thread709-1413694. Then read faq222-2244, especially the section on double posting.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top