我写了这个函数,用于选择“select all”选项的所有值
Private Function Not_Null()
If CmbGrade.Text = "SELECT ALL" Then
sql = "SELECT A.ROLLNO,A.FIRST_NAME,A.MIDDLE_NAME,A.LAST_NAME,A.ADDRESS,A.GRADE,B.DIV,A.BLOOD_GROUP,C.HOUSE,A.DATE_OF_BIRTH,A.TRANSPORT,A.SNAME,A.MEAL,A.RUTNO FROM STUDENT_RECORD_DATABASE A,DIVISION B,HNM C WHERE A.DIVID=B.DIVID AND A.HID=C.HID AND GRADE IS NOT NULL"
SET rs = cn.Execute(sql)
End If
End Function
在命令中调用此函数后,单击
Private Sub CmdReport_Click()
Dim STRp As String
STRp = Not_Null()
sql = "SELECT A.ROLLNO,A.FIRST_NAME,A.MIDDLE_NAME,A.LAST_NAME,A.ADDRESS,A.GRADE,B.DIV,A.BLOOD_GROUP,C.HOUSE,A.DATE_OF_BIRTH,A.TRANSPORT,A.SNAME,A.MEAL,A.RUTNO FROM STUDENT_RECORD_DATABASE A,DIVISION B,HNM C WHERE A.DIVID=B.DIVID AND A.HID=C.HID"
Set rs = cn.Execute(sql)
Set DataReport2.DataSource = rs
DataReport2.Show
End Sub
当我选择“全选”选项时,它不会显示任何记录 请帮助..........
答案 0 :(得分:4)
您执行STRp = Not_Null()
并不重要,因为(a)Not_Null
不返回值,(b)即使您正在执行SET rs
在Not_Null
中,即使假设您已在模块或表单中的某处声明rs
,您只需在CmdReport_Click
中覆盖其值。
试试这个:
Private Sub CmdReport_Click()
sql = "SELECT A.ROLLNO,A.FIRST_NAME,A.MIDDLE_NAME,A.LAST_NAME,A.ADDRESS,A.GRADE,B.DIV,A.BLOOD_GROUP,C.HOUSE,A.DATE_OF_BIRTH,A.TRANSPORT,A.SNAME,A.MEAL,A.RUTNO FROM STUDENT_RECORD_DATABASE A,DIVISION B,HNM C WHERE A.DIVID=B.DIVID AND A.HID=C.HID AND GRADE ='" & CmbGrade.Text & "'"
If CmbGrade.Text = "SELECT ALL" Then
sql = "SELECT A.ROLLNO,A.FIRST_NAME,A.MIDDLE_NAME,A.LAST_NAME,A.ADDRESS,A.GRADE,B.DIV,A.BLOOD_GROUP,C.HOUSE,A.DATE_OF_BIRTH,A.TRANSPORT,A.SNAME,A.MEAL,A.RUTNO FROM STUDENT_RECORD_DATABASE A,DIVISION B,HNM C WHERE A.DIVID=B.DIVID AND A.HID=C.HID AND GRADE IS NOT NULL"
End If
Set rs = cn.Execute(sql)
Set DataReport2.DataSource = rs
DataReport2.Show
End Sub
此外,很明显你甚至缺乏对编程语言(VB)的最基本的理解。我强烈建议你选择一本关于这个主题的入门书,或者在你继续学习之前搜索在线入门教程。