Public Sub cmdSearch_Click()
'Declarations'
Dim strSQL As String, strWhere As String, strOrder As String
Dim dbNm As Database
Dim qryDef As QueryDef
'Assignments'
Set dbNm = CurrentDb()
tblName = "tbl" & Me!cmbsource
strSQL = "SELECT [Page], [Date], Subject, Company, People, Diagram FROM " & tblName
strWhere = "WHERE"
strOrder = "ORDER BY " & tblName & ".Page"
'Error checking for two dates
If IsNull(Me.txtDate2) Or Me.txtDate2 = "" Then
MsgBox "Please enter an end date.", vbOKOnly, "Cannot perform search"
Else
'SQL Statement Construction'
If Not IsNull(Me.txtSubject) Then
strWhere = strWhere & " (" & tblName & ".Subject) Like '*" & Me.txtSubject & "*' AND"
End If
If Not IsNull(Me.txtPeople) Then
strWhere = strWhere & " (" & tblName & ".People) Like '*" & Me.txtPeople & "*' AND"
End If
If Not IsNull(Me.txtCompany) Then
strWhere = strWhere & " (" & tblName & ".Company) Like '*" & Me.txtCompany & "*' AND"
End If
If Not IsNull(Me.txtDate) Then
strWhere = strWhere & " (" & tblName & ".Date) Between #" & Me.txtDate & "# AND #" & Me.txtDate2 & "# AND"
End If
If Me.chkDiagram = True Then
strWhere = strWhere & " (" & tblName & ".Diagram) = TRUE AND"
Else
strWhere = strWhere & "(Diagram) = FALSE AND"
End If
'Remove the last AND from the SQL statment
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
'Pass the QueryDef to the query
Set qryDef = dbNm.QueryDefs("qrySearch"

qryDef.SQL = strSQL & " " & strWhere & " " & strOrder
End If
Me!frmSearchResults.Requery
End Sub
-------------
I might be thinking about doing a close and open form to just refresh it that way. I just can't get the open form function to work (hehe never actually used it). I'm quite young at Vb.