|
本帖最后由 秒弑 于 2012-1-4 11:16 编辑
如图,窗体出下:
窗体载入时,子窗体显示学生档案表,输入入学时间段后,再选择考试时间,按按钮得到入学时间段内某次考试的结果并显示在子窗体中。
问题1:子窗体不能显示非固定列的SQL查询结果,且报错。如图:
问题2:学生档案与成绩的交叉查询如何通过SQL代码实现?
附近上传,求高手解答,谢谢。
————————————————————————————
谢谢版主,已经解决了,用ADO那间临时表实现的。代码上传一下。里面有几句关于ADO的代码不太明白,不知道是否有不合理的地方。- Option Compare Database
- Private Sub ComboBiao_change()
- 'Dim strBiaoname As String
- 'strBiaoname = DLookup("表名", "学生成绩_表名", "说明 = '" & Me.ComboBiao.Value & "'")
- 'Me.ChildShow.SourceObject = "表." & strBiaoname
- 'Me.ChildShow.Requery
- End Sub
- Private Sub CommandClear_Click()
- Me.ChildShow.SourceObject = "表.学生档案"
- Me.ChildShow.Requery
- ComboBiao.Value = ""
- End Sub
- Private Sub CommandFind_Click()
- Dim rs As New ADODB.Recordset
- Dim strfind, strBiaoname As String
- Dim strTup, strTdown As Date
- Me.ChildShow.SourceObject = ""
- If Me.ComboBiao.Value <> "" Then
- strTup = Me.TextTup.Value
- strTdown = Me.TextTDown.Value
- strBiaoname = DLookup("表名", "学生成绩_表名", "说明 = '" & Me.ComboBiao.Value & "'")
- '删除临时表
- strfind = "drop table 临时表_成绩查询"
- rs.Open strfind, CurrentProject.Connection, 1, 3
- '建立临时表并显示
- strfind = "select 学生档案.ID,学生档案.姓名," & strBiaoname & ".语文," & strBiaoname & ".数学," & strBiaoname & ".英语 into 临时表_成绩查询 from 学生档案 INNER JOIN " & strBiaoname & " ON 学生档案.ID = " & strBiaoname & ".ID where 学生档案.入学时间 between # " & strTup & " # and #" & strTdown & "# "
- rs.Open strfind, CurrentProject.Connection, 1, 3
- Me.ChildShow.SourceObject = "表.临时表_成绩查询"
- Me.ChildShow.Requery
-
- Set rs = Nothing
- Else
- MsgBox "没有选择考试时间!"
- End If
- End Sub
- Private Sub Form_load()
- Me.ChildShow.SourceObject = "表.学生档案"
- End Sub
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|