KeithG said:
you should post your code and I will tell you.
Here's my code...
Private Sub Command15_Click()
Dim strSelect, strWhere, strFrom As String
Dim strNcTool, strNcDiv, strMaterial As String
Dim defQuery As QueryDef
strSelect = "SELECT [Tooling Information].[NC Tool #], [Tooling Information].[NC Division], [Tooling Information].[Profile # or Name], [Tooling Information].[Profile Type], [Tooling Information].[Tool Type], [Tooling Information].Notes, [Tooling Information].[Tool Material], [Tooling Information].[Shank Diameter], [Tooling Information].[Minor Diameter], [Tooling Information].[Max Cut Depth], [Tooling Information].[Board Thickness], [Tooling Information].[Tool Description], [Tooling Information].[Tool used in Fergus Falls - Veneer], [Tooling Information].[Tool used in Corbin - Thermofoil], [Tooling Information].[Tool used in Vanceburg, KY - Veneer], [Tooling Information].[Tool used in Vanceburg, KY - Wood], [Tooling Information].[Tool used in Arkansas City, KS - Veneer], [Tooling Information].[Tool used in Fergus Falls - Thermofoil], [Tooling Information].[AutoCAD File], [Tooling Information].[PDF File]"
strFrom = " FROM [Tooling Information]"
If IsNull(Me.cmbNCTool) = False Then
strWhere = " Where ([NC Tool #]='" & Me.cmbNCTool & "')"
End If
If IsNull(Me.cmbNCDivision) = False Then
If IsNull(strWhere) = False And Len(strWhere) > 2 Then
strWhere = strWhere & " AND ([NC Division]='" & Me.cmbNCDivision & "')"
Else
strWhere = " Where ([NC Division]='" & Me.cmbNCDivision & "')"
End If
End If
If IsNull(Me.cmbToolMaterial) = False Then
If IsNull(strWhere) = False And Len(strWhere) > 2 Then
strWhere = strWhere & " AND ([Tool Material]='" & Me.cmbToolMaterial & "')"
Else
strWhere = " Where([Tool Material]='" & Me.cmbToolMaterial & "')"
End If
End If
If IsNull(Me.Profile#) = False Then
If IsNull(strWhere) = False And Len(strWhere) > 2 Then
strWhere = strWhere & " AND ([Profile # or Name]='" & Me.Profile# & "')"
Else
strWhere = " Where ([Profile # or Name]='" & Me.Profile# & "')"
End If
End If
Set defQuery = CurrentDb.QueryDefs("Query1")
defQuery.SQL = strSelect & strFrom & strWhere
defQuery.Close
DoCmd.OpenForm "Tooling Information"
End Sub
I've also attached my file so you can look if you want to see what I did wrong.