実行エラー 3075:クエリ式`作成日 の間#2010/10/01#
実行エラー 3075:クエリ式`作成日 の間#2010/10/01# AND #2010/10/30#の構文エラー:演算子というエラーの処理をどうすればいいか分かりませんので教えてほしいです。
Private Sub cmdFilter_Click()
Dim strSQL As String
Dim strCriteria As String
With Me
If Len(.cboFieldName) <> 0 Then
If Len(.cboCondition) <> 0 Then
strCriteria = BuildCriteria(.cboFieldName.Column(0), _
.cboFieldName.Column(1), .cboCondition, _
Nz(.txtValue1), Nz(.txtValue2))
End If
End If
End With
With Me
ここはエラー→ .Filter = strCriteria
.FilterOn = True
.Requery
End With
Private Function BuildCriteria(strFieldName As String, _
intType As Integer, _
strCondition As String, _
varValue1 As Variant, _
Optional varValue2 As Variant) As String
Dim fBetween As Boolean
Dim fLike As Boolean
Dim strCriteria As String
Const conQuotes = """"
fBetween = IIf(InStr(strCondition, "の間") > 0, _
True, False)
fLike = IIf(InStr(strCondition, "類似") > 0, _
True, False)
strCriteria = strFieldName & " "
Select Case intType
Case dbText, dbMemo
If InStr(1, varValue1, "*") > 0 Then
strCriteria = strCriteria _
& " Like " & conQuotes & varValue1 & conQuotes
Else
If fLike Then
strCriteria = strCriteria & " 類似 " _
& conQuotes & "*" & varValue1 & "*" & conQuotes
Else
strCriteria = strCriteria & strCondition _
& " " & conQuotes & varValue1 & conQuotes
End If
End If
Case dbInteger, dbLong, dbCurrency, dbDouble, dbSingle
If fBetween Then
strCriteria = strCriteria _
& strCondition & " " & varValue1 & " AND " & varValue2
Else
strCriteria = strCriteria _
& strCondition & " " & varValue1
End If
Case dbDate
If fBetween Then
strCriteria = strCriteria & strCondition _
& " #" & Format(varValue1, "yyyy/mm/dd") & "# AND #" _
& Format(varValue2, "yyyy/mm/dd") & "#"
Else
strCriteria
お礼
昨日、頑張って調べた結果こういったものが出来ました! 返却値はInteger型になりましたけど・・・ Private Function strCheckTest(ByVal Expression As String) As Integer Dim Sc As Object Dim val As Integer Sc = CreateObject("ScriptControl") Sc.Language = "VBScript" val = Sc.Eval(Expression) Sc = Nothing Return val End Function ありがとうございます。