抽奖系统出现的from子语句语法错误,求解啊!
本帖最后由 xiji4482 于 2013-01-26 10:52:14 编辑 Private Sub Command5_Click(Index As Integer)
Select Case Index
Case 0
Data1.Refresh
Command5(0).Enabled = False
Command5(1).Enabled = True
Timer1.Enabled = True
Case 1
Command5(0).Enabled = True
Command5(2).Enabled = True
Timer1.Enabled = False
List1.AddItem (Data1.Recordset("学号"))
If cond = "" Then
cond = "学号<>'" & Data1.Recordset("学号") & "'"
Else
cond = cond + "and" + "学号<>'" & Data1.Recordset("学号") & "'"
End If
Data1.RecordSource = "select * from 学生 where" + cond
Case 2
List1.Visible = True
Case 3
End
End Select
End Sub
Private Sub Timer1_Timer()
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
Data1.Recordset.MoveFirst
End If
End Sub
单击command5(0)时,屏幕开始跳号,command5(1)为停止跳号,程序运行到这里都是好的,因为第一次出现的号码第二次再开始跳号抽奖时是会去除的,接下来我再次按command5(0)时出现了错误,错误提示为:实时错误“3131” ,from子语句语法错误。
求大神指点data1.refresh 这语句哪里有问题?调试时这语句被提示有误?
[解决办法]
1,SQL语句中加前后空格:
cond = cond + " and " + " 学号<>'" & Data1.Recordset("学号") & "'"
2,where后加1=1
Data1.RecordSource = "select * from 学生 where 1=1 " & cond