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 milage would then be used to calculate the travel cost. 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
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
Appreciate the help
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