标题:select 语法错误
取消只看楼主
yansfy
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-3-17
 问题点数:0 回复次数:0 
select 语法错误
各位大侠帮忙,看看错在哪里
Private Sub selcmd1_Click()
  Dim str As String
  str = ""
  If Trim(Text1.Text) <> "" Then
    If str = "" Then
      str = "姓名='" + Trim(Text1.Text) + "'"
    Else
      str = str + "and 姓名='" + Trim(Text1.Text) + "'"
    End If
  End If
  If Trim(DataCombo1.Text) <> "" Then
    If str = "" Then
      str = "所属系部='" + Trim(DataCombo1.Text) + "'"
    Else
      str = str + "and 所属系部='" + Trim(DataCombo1.Text) + "'"
    End If
  End If
  If Trim(DataCombo2.Text) <> "" Then
    If str = "" Then
      str = "职称='" + Trim(DataCombo2.Text) + "'"
    Else
      str = str + "and 职称='" + Trim(DataCombo2.Text) + "'"
    End If
  End If
  If Trim(DataCombo3.Text) <> "" Then
    If str = "" Then
      str = "课题级别='" + Trim(DataCombo3.Text) + "'"
    Else
      str = str + "and 课题级别='" + Trim(DataCombo3.Text) + "'"
    End If
  End If
  If Trim(Text2.Text) <> "" Then
      If str = "" Then
        str = "课题题目='" + Trim(Text2.Text) + "'"
      Else
        str = str + "and 课题题目='" + Trim(Text2.Text) + "'"
      End If
  End If
  If Trim(DataCombo3.Text) <> "" Then
    If str = "" Then
      str = "奖励级别='" + Trim(DataCombo3.Text) + "'"
    Else
      str = str + "and 奖励级别='" + Trim(DataCombo3.Text) + "'"
    End If
  End If
  If str <> "" Then
    If DTPicker1.Value = DTPicker2.Value Then
      Adodc1.RecordSource = "select * from jiaoyanjiaogaiketi where " + str
      Adodc1.Refresh
    Else
      Adodc1.RecordSource = "select * from jiaoyanjiaogaiketi where " + str + "and 开题时间 between '" & CDate(DTPicker1.Value) & "'and '" & CDate(DTPicker2.Value) & "'"
      Adodc1.Refresh
    End If
  Else
    Adodc1.RecordSource = "select * from jiaoyanjiaogaiketi"
    Adodc1.Refresh
  End If
  recs = Adodc1.Recordset.RecordCount
  If recs = 0 Then
    MsgBox "没有任何满足条件的记录", vbOKOnly, "信息提示"
  End If
  Call encomm
End Sub
搜索更多相关主题的帖子: select 语法 
2008-03-17 15:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-203831-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.275745 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved