pwise, I'm not sure what you mean, I'm new to all this. Here is the code I used for the search. Everything works fine except it will not requery the form unless I close and reopen it. Thanks
Private Sub Search_Data_Click()
' Pointer to error handler
On Error GoTo Search_Data_Click_err
' Declare variables
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strZone As String
Dim strScrap As String
Dim strTag As String
Dim strBldg As String
Dim strContact As String
Dim strDesc As String
Dim strSQL As String
Dim stDocName As String
Dim stRepName As String
Dim frmMain As Form
Set frmMain = Forms!FormZoneAll
' Identify the database and assign it to the variable
Set db = CurrentDb
' Check for the existence of the query, create it if not found,
' and assign it to the variable
If Not QueryExists("qryLookUp") Then
Set qdf = db.CreateQueryDef("qryLookUp")
Else
Set qdf = db.QueryDefs("qryLookUp")
End If
' Get the values from the combo boxes
If IsNull(Me.cboZone.Value) Then
strZone = " Like '*' "
Else
strZone = "=" & Me.cboZone.Value & " "
End If
If IsNull(Me.cboScrap.Value) Then
strScrap = " Like '*' "
Else
strScrap = "='" & Me.cboScrap.Value & "' "
End If
If IsNull(Me.cboBldg.Value) Then
strBldg = " Like '*' "
Else
strBldg = "='" & Me.cboBldg.Value & "' "
End If
If IsNull(Me.cboContact.Value) Then
strContact = " Like '*' "
Else
strContact = "='" & Me.cboContact.Value & "' "
End If
If IsNull(Me.cboDesc.Value) Then
strDesc = " Like '*' "
Else
strDesc = "='" & Me.cboDesc.Value & " '"
End If
If IsNull(Me.cboTag.Value) Then
strDesc = " Like '*' "
Else
strDesc = "='" & Me.cboTag.Value & " '"
End If
strSQL = "SELECT [ID], [Contact], [Item], [BusinessModel], [equip],[Zone].Tag_Red_Yellow, [KeeporScrap], " & _
"[EquipID], [Asset], [Description], [Manufacturer], [Model], [CLBldg], [CLRoom], [FLBldg]," & _
"[FLRoom], [Zone]" & _
"FROM [Zone] " & _
"WHERE [Zone].Zone" & strZone & _
"And [Zone].KeeporScrap" & strScrap & _
"And [Zone].[Tag_Red_Yellow]" & strTag & _
"And [Zone].CLBldg" & strBldg & _
"And [Zone].Contact" & strContact & _
"And [Zone].Description" & strDesc & _
"ORDER BY [Zone].Zone;"
' Pass the SQL string to the query
qdf.SQL = strSQL
' Turn off screen updating
DoCmd.Echo False
' Check the state of the query and close it if it is open
If Application.SysCmd(acSysCmdGetObjectState, acQuery, "qryLookUp") = acObjStateOpen Then
DoCmd.Close acQuery, "qryLookUp"
End If
' Open the report
stDocName = "qryLookUp"
stRepName = "SHIREall"
If IsNull(Me.RepType.Value) Then
DoCmd.OpenReport stRepName, acViewPreview
Else
If Me.RepType.Value = "Access" Then
DoCmd.OpenReport stRepName, acViewPreview
Else
If Me.RepType.Value = "Excell" Then
DoCmd.OutputTo acOutputQuery, stDocName, acFormatXLS, "C:\Test.xls", True
End If
End If
End If
Search_Data_Click_exit:
' Turn on screen updating
DoCmd.Echo True
' Clear the object variables
Set qdf = Nothing
Set db = Nothing
Exit Sub
Search_Data_Click_err:
' Handle errors
MsgBox "An unexpected error has occurred." & _
vbCrLf & "Please note of the following details:" & _
vbCrLf & "Error Number: " & Err.Number & _
vbCrLf & "Description: " & Err.Description _
, vbCritical, "Error"
Resume Search_Data_Click_exit
frmMain.Recordset.Requery
End Sub