Office中国论坛/Access中国论坛

标题: 请帮解决SQI的问题 [打印本页]

作者: kill718    时间: 2008-3-10 19:23
标题: 请帮解决SQI的问题
Function GetSQL(strTable As String) As String
On Error GoTo Err_GetSQL
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String, strSQLWhere As String
Dim strOperation As String, i As Integer
Dim intCount As Integer
strSQL = "SELECT * FROM tblSearch "
strSQL = strSQL & "WHERE (Field Is Not Null) And (KeyWord Is Not Null)"
Set conn = CurrentProject.Connection
rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic
intCount = rs.RecordCount
If intCount = 0 Then
    GetSQL = "SELECT * FROM [" & strTable & "];"
Else
    For i = 1 To intCount
        If rs("Operation1") = conAND Then
            strOperation = " And "
        ElseIf rs("Operation1") = conOR Then
            strOperation = " Or "
        End If
        If intCount = 1 Then
            strSQLWhere = GetSQLWhere(rs("Field"), rs("KeyWord"), rs("Operation2"))
        Else
            If i = 1 Then
                strSQLWhere = strSQLWhere & GetSQLWhere(rs("Field"), rs("KeyWord"), rs("Operation2"))
            Else
                strSQLWhere = strSQLWhere & strOperation & GetSQLWhere(rs("Field"), rs("KeyWord"), rs("Operation2"))
            End If
        End If
        rs.MoveNext
    Next
    GetSQL = "SELECT * FROM [" & strTable & "] WHERE " & strSQLWhere & ";"
End If
    rs.Close
    Set rs = Nothing
    Set conn = Nothing


请问大虾红色部分是什么意思,谢谢
作者: kill718    时间: 2008-3-11 19:27
要是字段是空的会出现什么样的现象啊
作者: glw    时间: 2008-3-11 22:30
原帖由 kill718 于 2008-3-11 19:27 发表
要是字段是空的会出现什么样的现象啊

strSQL = strSQL & "WHERE (Field Is  Null) And (KeyWord Is  Null)"
自己试一下不就知道了




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3