I am trying to create a a form with a subform that can search through a table of Construction Subcontractors based on Company Name, POC Name, Type, Division, and Entity. Information is entered into the form and then the results are displayed in the subform. I have copied and pasted a form from a template on Office.com called Issues. The Issues database is in Access 2003 and I am working with Access 2010. I put the form and subform into my database and tried to change the neccessary field names. However, I get a "Compile error: Varible not defined" every time i try to run the search. Here is the code behind the search command button:
Option Compare Database
Option Explicit
Private Sub Clear_Click()
DoCmd.Close
DoCmd.OpenForm "Search Issues"
End Sub
Private Sub Search_Click()
strWhere = "1=1"
' If Division
If Not IsNull(Me.Division) Then
'Create Predicate
strWhere = strWhere & " AND " & "Subcontractors.[Divsion] = " & Me.Division & ""
End If
' If Entity
If Nz(Me.Entity) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "Subcontractors.Entity = '" & Me.Entity & "'"
End If
' If Company Name
If Nz(Me.CompanyName) <> "" Then
' Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "Subcontractors.[Company Name] Like '*" & Me.CompanyName & "*'"
End If
' If POC Name
If Nz(Me.POCName) <> "" Then
' Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "Subcontractors.[POC Name] Like '*" & Me.POCName & "*'"
End If
' If Type
If Nz(Me.Type) <> "" Then
' Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "Subcontractors.Type Like '*" & Me.Type & "*'"
End If
Else
'DoCmd.OpenForm "Browse All Issues", acFormDS, , strWhere, acFormEdit, acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Issues.Form.Filter = strWhere
Me.Browse_All_Issues.Form.FilterOn = True
End If
End Sub
The Debugger goes to the Private Sub Search_Click() line. Is the problem coming from the previous database being in Access 2003?? Or do I have some other problem within my code or form?? I am a newb at access and I know very little about writing code, so any help would be greatly appreciated.