Hello,
I need some help with adding to an existing database. Our database is searchable by two basic criteria, Projects or Units. These are two seperate tables, each with their respective variables. The search can run according to some variables, but not all (ie. size, but not date). I wish to add the ability to search by date. Below is the code for the Units search so far.....
Private Sub Command17_Click()
Dim strSQL As String
strSQL = "SELECT * FROM Units WHERE "
strSQL = strSQL & "SquareFootage BETWEEN " & SqFootMin & " AND " & SqFootMax
strSQL = strSQL & " AND Width < " & Me.WidthMax
strSQL = strSQL & " AND Depth < " & Me.DepthMax
If Me.Floors > "" Then
strSQL = strSQL & " AND Floors = " & Me.Floors
End If
If Me.Master > "" Then
strSQL = strSQL & " AND Master = " & Me.Master
End If
If Me.Baths > "" Then
strSQL = strSQL & " AND Baths = " & Me.Baths
End If
If Me.Bedrooms > "" Then
strSQL = strSQL & " AND Bedrooms = " & Me.Bedrooms
End If
If Me.GarageStalls > "" Then
strSQL = strSQL & " AND GarageStalls = " & Me.GarageStalls
End If
If Me.UnitDescription > "" Then
strSQL = strSQL & " AND UnitDescription LIKE " & Me.UnitDescription
End If
DoCmd.OpenForm "Unit Results", acFormDS
'MsgBox strSQL
Forms![Unit Results].RecordSource = strSQL
End Sub
Any help would be GREAT.
Thank you
I need some help with adding to an existing database. Our database is searchable by two basic criteria, Projects or Units. These are two seperate tables, each with their respective variables. The search can run according to some variables, but not all (ie. size, but not date). I wish to add the ability to search by date. Below is the code for the Units search so far.....
Private Sub Command17_Click()
Dim strSQL As String
strSQL = "SELECT * FROM Units WHERE "
strSQL = strSQL & "SquareFootage BETWEEN " & SqFootMin & " AND " & SqFootMax
strSQL = strSQL & " AND Width < " & Me.WidthMax
strSQL = strSQL & " AND Depth < " & Me.DepthMax
If Me.Floors > "" Then
strSQL = strSQL & " AND Floors = " & Me.Floors
End If
If Me.Master > "" Then
strSQL = strSQL & " AND Master = " & Me.Master
End If
If Me.Baths > "" Then
strSQL = strSQL & " AND Baths = " & Me.Baths
End If
If Me.Bedrooms > "" Then
strSQL = strSQL & " AND Bedrooms = " & Me.Bedrooms
End If
If Me.GarageStalls > "" Then
strSQL = strSQL & " AND GarageStalls = " & Me.GarageStalls
End If
If Me.UnitDescription > "" Then
strSQL = strSQL & " AND UnitDescription LIKE " & Me.UnitDescription
End If
DoCmd.OpenForm "Unit Results", acFormDS
'MsgBox strSQL
Forms![Unit Results].RecordSource = strSQL
End Sub
Any help would be GREAT.
Thank you