Jerry,
Thanks for the Help I am still having problems on where to insert the TOP Value SQL exression. I am trying to get the top 3 in my query to show up in my subform6. I attempted to write another sql command titled strGetSQL. Everytime I try to run this there says there is a syntax error.Any ideas on the possible errors? does my code look alright?
Below is the code listed
Private Sub CalculateZip_Click()
Dim sqlString As String
Dim strGetSQL 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
strGetSQL = "SELECT TOP 3 [Service Agent],State,city" _
& "FROM Forms!SA_Distance_Calc_subform6" _
& "WHERE [Zodiaq Zip Locations_Zip] = Forms!SA_Distance_Calc_subform6!Combo14.Value" _
& "ORDER BY [Travel Cost];"
Me.SA_Distance_Calc_subform6.Form.FilterOn = True
Me.SA_Distance_Calc_subform6.Form.Filter = strGetSQL
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