kellielewis2872
New member
- Local time
- Today, 18:45
- Joined
- Apr 30, 2012
- Messages
- 9
I am having trouble with the correct syntax in the line that is using the Like statement. Here is the complete function. If someone could help me I would greatly appreciate it.
Function BuildSQLString(sSQL As String) As Boolean
Dim sSELECT As String
Dim sFROM As String
Dim sWHERE As String
sSELECT = "s.timereport "
sFROM = "DAILYSERVICEANDTIMEREPORT s "
If CheckLocation Then
sWHERE = sWHERE & " AND s.CustomerID = " & ComboLocation
End If
If Checkcontacted Then
sWHERE = sWHERE & " AND s.CONTACTEDBY = " & textcontacted
End If
If CheckDescription Then
sWHERE = sWHERE & " AND s.DESCRIPTIONOFWORKPERFORMED =" & Like '*" & TEXTDESCRIPTION & "*'"
End If
If CheckDate1 Then
If Not IsNull(TextDate1) Then
sWHERE = sWHERE & " AND s.TransactionCreatedDate >= " & _
"#" & Format$(TextDate1, "mm/dd/yy") & "#"
End If
If Not IsNull(TextDate2) Then
sWHERE = sWHERE & " AND s.TransactionCreatedDate <= " & _
"#" & Format$(TextDate2, "mm/dd/yy") & "#"
End If
End If
sSQL = "SELECT " & sSELECT
sSQL = sSQL & "FROM " & sFROM
If sWHERE <> "" Then sSQL = sSQL & "WHERE " & Mid$(sWHERE, 6)
BuildSQLString = True
End Function
Function BuildSQLString(sSQL As String) As Boolean
Dim sSELECT As String
Dim sFROM As String
Dim sWHERE As String
sSELECT = "s.timereport "
sFROM = "DAILYSERVICEANDTIMEREPORT s "
If CheckLocation Then
sWHERE = sWHERE & " AND s.CustomerID = " & ComboLocation
End If
If Checkcontacted Then
sWHERE = sWHERE & " AND s.CONTACTEDBY = " & textcontacted
End If
If CheckDescription Then
sWHERE = sWHERE & " AND s.DESCRIPTIONOFWORKPERFORMED =" & Like '*" & TEXTDESCRIPTION & "*'"
End If
If CheckDate1 Then
If Not IsNull(TextDate1) Then
sWHERE = sWHERE & " AND s.TransactionCreatedDate >= " & _
"#" & Format$(TextDate1, "mm/dd/yy") & "#"
End If
If Not IsNull(TextDate2) Then
sWHERE = sWHERE & " AND s.TransactionCreatedDate <= " & _
"#" & Format$(TextDate2, "mm/dd/yy") & "#"
End If
End If
sSQL = "SELECT " & sSELECT
sSQL = sSQL & "FROM " & sFROM
If sWHERE <> "" Then sSQL = sSQL & "WHERE " & Mid$(sWHERE, 6)
BuildSQLString = True
End Function