Office中国论坛/Access中国论坛

标题: 这段代码?是什么意思。 [打印本页]

作者: 2pl01    时间: 2009-12-8 15:57
标题: 这段代码?是什么意思。
Private Function fill_subForm()
    On Error GoTo Exit_Err
    Dim CX As Integer
    Dim i As Integer
    strCurTable = IIf(Me!chkColHead, strTmpTableA, strTmpTableB)
    Me.subFrm.Form.RecordSource = strCurTable
    Dim xRst As ADODB.Recordset
    Set xRst = CurrentProject.Connection.Execute("Select  * From " & strCurTable)
    CX = xRst.Fields.Count
    strFstItem = xRst.Fields(0).Name
    strFstType = xRst.Fields(0).Type
    strCurItem = ""
    For i = 1 To CX
        If strCurItem <> "" Then strCurItem = strCurItem & ";"
        strCurItem = strCurItem & xRst.Fields(i - 1).Name
        If Not Me!chkColHead Then
            Me!subFrm.Form("lblTit" & i).Caption = ""
        Else
            Me!subFrm.Form("lblTit" & i).Caption = xRst.Fields(i - 1).Name
        End If
        Me!subFrm.Form("txtNR" & i).ControlSource = xRst.Fields(i - 1).Name
    Next
    If CX = Me!subFrm.Form.Controls.Count / 2 Then Exit Function
    For i = CX + 1 To Me!subFrm.Form.Controls.Count / 2
        Me!subFrm.Form("txtNR" & i).ColumnHidden = True
        Me!subFrm.Form("txtNR" & i).ColumnWidth = 0
    Next
    xRst.Close
    Set xRst = Nothing
    Me!subFrm.Form!txtNR1.ColumnHidden = False
    Me!chkColHead.Enabled = True
    Me!chkFirstCol.Enabled = True
    Me!cmdXMDB.Enabled = True
    Me!cmdDel.Enabled = True
    Exit Function
Exit_Err:
    MsgBox "错误:" & Err.Number & "," & Err.Description, 64, "提示"
    Exit Function
End Function




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