Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "add"
    Label16.Caption = "开户金额"
    For i = 0 To Controls.Count - 1
        If TypeOf Controls(i) Is TextBox Then
            Controls(i).Enabled = True
            Controls(i).Text = ""
        End If
    Next
    optMale.Enabled = True
    optFemale.Enabled = True
    cboMonth.Enabled = True
    cboDay.Enabled = True
    cboAccountTypeID.Enabled = True
    chkATM.Enabled = True
    chkCheckBook.Enabled = True
    txtATMCardNumber.Enabled = False
    txtATMAccessCode.Enabled = False
    txtCheckBookNumber.Enabled = False
    txtStartNumber.Enabled = False
    txtEndNumber.Enabled = False
    
    Rs.AddNew
    Call allow
    
    Dim comPrc As Command
    Dim prmOfPrc As Parameter
    Dim strCustomerID As String
    
    Set prmOfPrc = New Parameter
    Set comPrc = New Command
    comPrc.ActiveConnection = con
    
    comPrc.CommandType = adCmdStoredProc
    comPrc.CommandText = "prcCustomerAutoGen"
    
    Set prmOfPrc = comPrc.CreateParameter("CustomerID", adInteger, adParamOutput)
    comPrc.Parameters.Append prmOfPrc
    comPrc.Execute
    If comPrc(0) < 10 Then
        strCustomerID = "000000000" + CStr(comPrc(0))
    ElseIf comPrc(0) < 100 Then
        strCustomerID = "00000000" + CStr(comPrc(0))
    ElseIf comPrc(0) < 1000 Then
        strCustomerID = "0000000" + CStr(comPrc(0))
    ElseIf comPrc(0) < 10000 Then
        strCustomerID = "000000" + CStr(comPrc(0))
    ElseIf comPrc(0) < 100000 Then
        strCustomerID = "00000" + CStr(comPrc(0))
    ElseIf comPrc(0) < 1000000 Then
        strCustomerID = "0000" + CStr(comPrc(0))
    ElseIf comPrc(0) < 10000000 Then
        strCustomerID = "000" + CStr(comPrc(0))
    ElseIf comPrc(0) < 100000000 Then
        strCustomerID = "00" + CStr(comPrc(0))
    ElseIf comPrc(0) < 1000000000 Then
        strCustomerID = "0" + CStr(comPrc(0))
    End If
    txtID.Text = strCustomerID
    
    Set comPrc = Nothing
    Set prmOfPrc = Nothing
    Command1.Enabled = False
Case "save"
    blnStatus = True
    For i = 0 To Controls.Count - 1
        If TypeOf Controls(i) Is TextBox And Controls(i).Enabled = True Then
            If Controls(i).Text = "" Then
                MsgBox "资料填写不完整,请检查", vbInformation, "帐户管理"
                blnStatus = False
                Exit Sub
            End If
        End If
    Next
    
    If cboMonth.Text = "" Then
        MsgBox "请选择月份", vbInformation, "帐户管理"
        blnStatus = False
        Exit Sub
    End If
    
    If cboDay.Text = "" Then
        MsgBox "请选择日期", vbInformation, "帐户管理"
        blnStatus = False
        Exit Sub
    End If
    
    If chkATM.Value = 1 Then
        If txtATMCardNumber = "" Or txtATMAccessCode = "" Then MsgBox "请填写信用卡相关信息", vbInformation, "帐户管理"
        blnStatus = False
        Exit Sub
    End If
    
    If chkCheckBook.Value = 1 Then
        If txtCheckBookNumber = "" Or txtStartNumber = "" Or txtEndNumber = "" Then MsgBox "请填写支票相关信息", vbInformation, "帐户管理"
        blnStatus = False
        Exit Sub
    End If
    
    If blnStatus = True Then
        Rs("cCustomerID") = Trim(txtID.Text)
        Rs("vCustomerName") = Trim(txtName.Text)
        Rs("vCustomerAddress") = Trim(txtAddress.Text)
        
        Rs("dDateOfBirth") = Trim(txtYear.Text) & "-" & Trim(cboMonth.Text) & "-" & Trim(cboDay.Text)
        
        If Len(Trim(txtArea.Text)) = 3 Then txtArea.Text = "0" & Trim(txtArea.Text)
        If Len(Trim(txtPhone.Text)) = 7 Then txtPhone.Text = "0" & Trim(txtPhone.Text)
        Rs("vCustomerPhone") = "(" & txtArea.Text & ")-" & Trim(txtPhone.Text)
        
        If optMale.Value = True Then
            Rs("cGender") = "M"
        ElseIf optFemale.Value = True Then
            Rs("cGender") = "F"
        End If
        
        Rs("vEmail") = Trim(txtEmail.Text)
        Rs("vPicture") = Trim(txtPicture.Text)
        Rs("cIDCardNo") = Trim(txtIDCardNo.Text)
        Rs("cAccountNumber") = Trim(txtAccountNumber.Text)
        Rs("cAccountTypeID") = Mid(Trim(cboAccountTypeID.Text), 1, 4)
        Rs("cAccessCode") = Trim(txtAccessCode.Text)
        Rs("mAccountBalance") = Val(Trim(txtAccountBalance.Text))
        ////////////////////////////////////////////////////////////
        If chkATM.Value = 1 Then
            Rs("cATMCardNumber") = Trim(Me.txtATMCardNumber.Text)
            Rs("cATMAccessCode") = Trim(Me.txtATMAccessCode.Text)
            Rs("dCardOpenedDate") = Format(Date, DATEFORMAT)
        End If
        
        If chkCheckBook.Value = 1 Then
            Rs("vCheckBookNumber") = Trim(Me.txtCheckBookNumber.Text)
            Rs("dDateIssued") = Format(Date, DATEFORMAT)
            Rs("vStartNumber") = Trim(Me.txtStartNumber.Text)
            Rs("vEndNumber") = Trim(Me.txtEndNumber.Text)
            Rs("dCheckBookOpenedDate") = Format(Date, DATEFORMAT)
        End If
问题出在这里:可能是三层Frame控件嵌套的问题(Frame中有Frame,Frame中又有Frame,主要是为了划分界面用),点击保存按钮没有反应,但是如果没有选择这两个复选,可以保存,请问取嵌套在Frame控件中的控件的数据。还是什么地方出错了,帮忙看一下
        /////////////////////////////////////////////////////////////
        Rs("dAccountOpenedDate") = Format(Date, DATEFORMAT)
        Rs("cLoginID") = strOperator
        Rs.Update
        MsgBox "记录已经成功保存到数据库", vbInformation, "帐户管理"
        Call fillList
        For i = 0 To Controls.Count - 1
            If TypeOf Controls(i) Is TextBox Then Controls(i).Enabled = False
        Next
        optMale.Enabled = False
        optFemale.Enabled = False
        cboMonth.Enabled = False
        cboDay.Enabled = False
        cboAccountTypeID.Enabled = False
        chkATM.Enabled = False
        chkCheckBook.Enabled = False
        Call disallow
        Command1.Enabled = True
        Label16.Caption = "帐户余额"
    End If

解决方案 »

  1.   

    (续)
    Case "delete"
        If Rs.BOF = True Then
            MsgBox "没有任何帐户档案记录,不能进行销户操作", vbInformation, "帐户管理"
            Toolbar1.Buttons(3).Enabled = False
            Exit Sub
        End If
        On Error GoTo errorhandler
        Rs.Delete
        Rs.MoveNext
        If Rs.EOF = True Then
            Rs.Requery
            If Rs.BOF = True Then
                MsgBox "现在已经没有任何帐户档案记录", vbInformation, "帐户管理"
                For i = 0 To Controls.Count - 1
                    If TypeOf Controls(i) Is TextBox Then Controls(i).Text = ""
                Next
                Toolbar1.Buttons(3).Enabled = False
                List1.Clear
                Exit Sub
            End If
        End If
        Call fillList
        Exit Sub
    errorhandler:
       MsgBox Err.Number & "," & Err.Source & "," & Err.Description, vbInformation, "帐户管理"
       Unload Me
    Case "cancel"
        Rs.CancelUpdate
        On Error GoTo errorhandler_cancel
        Rs.MoveFirst
    errorhandler_cancel:
        If Rs.BOF = True Then
            For i = 0 To Controls.Count - 1
                If TypeOf Controls(i) Is TextBox Then
                    Controls(i).Enabled = False
                    Controls(i).Text = ""
                End If
            Next
            optMale.Enabled = False
            optFemale.Enabled = False
            cboMonth.Enabled = False
            cboDay.Enabled = False
            cboAccountTypeID.Enabled = False
            chkATM.Enabled = False
            chkCheckBook.Enabled = False
            Call disallow
            Command1.Enabled = True
            Exit Sub
            Label16.Caption = "帐户余额"
        End If
        
        Call display
        For i = 0 To Controls.Count - 1
            If TypeOf Controls(i) Is TextBox Then Controls(i).Enabled = False
        Next
        optMale.Enabled = False
        optFemale.Enabled = False
        cboMonth.Enabled = False
        cboDay.Enabled = False
        cboAccountTypeID.Enabled = False
        chkATM.Enabled = False
        chkCheckBook.Enabled = False
        Call disallow
        Command1.Enabled = True
        Label16.Caption = "帐户余额"
    Case "update"
        If Rs.BOF = True Then
            MsgBox "没有任何帐户档案记录,不能进行更新操作", vbInformation, "帐户管理"
            Toolbar1.Buttons(5).Enabled = False
            Exit Sub
        End If
        For i = 0 To Controls.Count - 1
            If TypeOf Controls(i) Is TextBox Then Controls(i).Enabled = True
        Next
        optMale.Enabled = True
        optFemale.Enabled = True
        cboMonth.Enabled = True
        cboDay.Enabled = True
        cboAccountTypeID.Enabled = True
        
        chkATM.Enabled = False
        chkCheckBook.Enabled = False
        txtATMCardNumber.Enabled = False
        txtATMAccessCode.Enabled = False
        txtCheckBookNumber.Enabled = False
        txtStartNumber.Enabled = False
        txtEndNumber.Enabled = False
        txtID.Enabled = False
        txtAccountNumber.Enabled = False
        cboAccountTypeID.Enabled = False
        txtAccountBalance.Enabled = False
        Call allow
        Command1.Enabled = False
    Case "exit"
        Unload Me
    End Select
    End Sub
      

  2.   

    建议你分开几个过程,代码可读性会好一些.
    Frame有几层不会影响CheckBox的值.
    你在下面的赋值语句中可能有某行出错,建议你调试一下.
           If chkATM.Value = 1 Then
                Rs("cATMCardNumber") = Trim(Me.txtATMCardNumber.Text)
                Rs("cATMAccessCode") = Trim(Me.txtATMAccessCode.Text)
                Rs("dCardOpenedDate") = Format(Date, DATEFORMAT)
            End If
            
            If chkCheckBook.Value = 1 Then
                Rs("vCheckBookNumber") = Trim(Me.txtCheckBookNumber.Text)
                Rs("dDateIssued") = Format(Date, DATEFORMAT)
                Rs("vStartNumber") = Trim(Me.txtStartNumber.Text)
                Rs("vEndNumber") = Trim(Me.txtEndNumber.Text)
                Rs("dCheckBookOpenedDate") = Format(Date, DATEFORMAT)
            End If
      

  3.   

    Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    Select Case Button.Key
    Case "add"
        Label16.Caption = "开户金额"
        For i = 0 To Controls.Count - 1
            If TypeOf Controls(i) Is TextBox Then
                Controls(i).Enabled = True
                Controls(i).Text = ""
            End If
        Next
        optMale.Enabled = True
        optFemale.Enabled = True
        cboMonth.Enabled = True
        cboDay.Enabled = True
        cboAccountTypeID.Enabled = True
        chkAtm.Enabled = True
        chkCheckbook.Enabled = True
        chkAtm.Value = 0
        chkCheckbook.Value = 0
        txtATMCardNumber.Enabled = False
        txtATMAccessCode.Enabled = False
        txtCheckBookNumber.Enabled = False
        txtStartNumber.Enabled = False
        txtEndNumber.Enabled = False
        
        Rs.AddNew
        Call allow
        
        Dim comPrc As Command
        Dim prmOfPrc As Parameter
        Dim strCustomerID As String
        
        Set prmOfPrc = New Parameter
        Set comPrc = New Command
        comPrc.ActiveConnection = con
        
        comPrc.CommandType = adCmdStoredProc
        comPrc.CommandText = "prcCustomerAutoGen"
        
        Set prmOfPrc = comPrc.CreateParameter("CustomerID", adInteger, adParamOutput)
        comPrc.Parameters.Append prmOfPrc
        comPrc.Execute
        If comPrc(0) < 10 Then
            strCustomerID = "000000000" + CStr(comPrc(0))
        ElseIf comPrc(0) < 100 Then
            strCustomerID = "00000000" + CStr(comPrc(0))
        ElseIf comPrc(0) < 1000 Then
            strCustomerID = "0000000" + CStr(comPrc(0))
        ElseIf comPrc(0) < 10000 Then
            strCustomerID = "000000" + CStr(comPrc(0))
        ElseIf comPrc(0) < 100000 Then
            strCustomerID = "00000" + CStr(comPrc(0))
        ElseIf comPrc(0) < 1000000 Then
            strCustomerID = "0000" + CStr(comPrc(0))
        ElseIf comPrc(0) < 10000000 Then
            strCustomerID = "000" + CStr(comPrc(0))
        ElseIf comPrc(0) < 100000000 Then
            strCustomerID = "00" + CStr(comPrc(0))
        ElseIf comPrc(0) < 1000000000 Then
            strCustomerID = "0" + CStr(comPrc(0))
        End If
        txtID.Text = strCustomerID
        
        Set comPrc = Nothing
        Set prmOfPrc = Nothing
        Command1.Enabled = False
    Case "save"
        blnStatus = True
        For i = 0 To Controls.Count - 1
            If TypeOf Controls(i) Is TextBox And Controls(i).Enabled = True Then
                If Controls(i).Text = "" Then
                    MsgBox "资料填写不完整,请检查", vbInformation, "帐户管理"
                    blnStatus = False
                    Exit Sub
                End If
            End If
        Next
        
        If cboMonth.Text = "" Then
            MsgBox "请选择月份", vbInformation, "帐户管理"
            blnStatus = False
            Exit Sub
        End If
        
        If cboDay.Text = "" Then
            MsgBox "请选择日期", vbInformation, "帐户管理"
            blnStatus = False
            Exit Sub
        End If
        
        If chkAtm.Value = 1 And (txtATMCardNumber = "" Or txtATMAccessCode = "") Then
            MsgBox "请填写信用卡相关信息", vbInformation, "帐户管理"
            blnStatus = False
            Exit Sub
        End If
        
        If chkCheckbook.Value = 1 And (txtCheckBookNumber = "" Or txtStartNumber = "" Or txtEndNumber = "") Then
            MsgBox "请填写支票相关信息", vbInformation, "帐户管理"
            blnStatus = False
            Exit Sub
        End If
        
        If blnStatus = True Then
            Rs("cCustomerID") = Trim(txtID.Text)
            Rs("vCustomerName") = Trim(txtName.Text)
            Rs("vCustomerAddress") = Trim(txtAddress.Text)
            
            Rs("dDateOfBirth") = Trim(txtYear.Text) & "-" & Trim(cboMonth.Text) & "-" & Trim(cboDay.Text)
            
            If Len(Trim(txtArea.Text)) = 3 Then txtArea.Text = "0" & Trim(txtArea.Text)
            If Len(Trim(txtPhone.Text)) = 7 Then txtPhone.Text = "0" & Trim(txtPhone.Text)
            Rs("vCustomerPhone") = "(" & txtArea.Text & ")-" & Trim(txtPhone.Text)
            
            If optMale.Value = True Then
                Rs("cGender") = "M"
            ElseIf optFemale.Value = True Then
                Rs("cGender") = "F"
            End If
            
            Rs("vEmail") = Trim(txtEmail.Text)
            Rs("vPicture") = Trim(txtPicture.Text)
            Rs("cIDCardNo") = Trim(txtIDCardNo.Text)
            Rs("cAccountNumber") = Trim(txtAccountNumber.Text)
            Rs("cAccountTypeID") = Mid(Trim(cboAccountTypeID.Text), 1, 4)
            Rs("cAccessCode") = Trim(txtAccessCode.Text)
            Rs("mAccountBalance") = Val(Trim(txtAccountBalance.Text))
            
            If chkAtm.Value = 1 Then
                Rs("cATMCardNumber") = Trim(txtATMCardNumber.Text)
                Rs("cATMAccessCode") = Trim(txtATMAccessCode.Text)
                Rs("dCardOpenedDate") = Format(Date, DATEFORMAT)
            End If
            
            If chkCheckbook.Value = 1 Then
                Rs("vCheckBookNumber") = Trim(txtCheckBookNumber.Text)
                Rs("dDateIssued") = Format(Date, DATEFORMAT)
                Rs("vStartNumber") = Trim(txtStartNumber.Text)
                Rs("vEndNumber") = Trim(txtEndNumber.Text)
                Rs("dCheckBookOpenedDate") = Format(Date, DATEFORMAT)
            End If
            
            Rs("dAccountOpenedDate") = Format(Date, DATEFORMAT)
            Rs("cLoginID") = strOperator
            Rs.Update
            MsgBox "记录已经成功保存到数据库", vbInformation, "帐户管理"
            
            Call fillList
            For i = 0 To Controls.Count - 1
                If TypeOf Controls(i) Is TextBox Then Controls(i).Enabled = False
            Next
            optMale.Enabled = False
            optFemale.Enabled = False
            chkAtm.Enabled = False
            chkCheckbook.Enabled = False
            cboMonth.Enabled = False
            cboDay.Enabled = False
            cboAccountTypeID.Enabled = False
            Call disallow
            Command1.Enabled = True
            Label16.Caption = "帐户余额"
        End If
      

  4.   

    Case "delete"
        If Rs.BOF = True Then
            MsgBox "没有任何帐户档案记录,不能进行销户操作", vbInformation, "帐户管理"
            Toolbar1.Buttons(3).Enabled = False
            Exit Sub
        End If
        On Error GoTo errorhandler
        Rs.Delete
        Rs.MoveNext
        If Rs.EOF = True Then
            Rs.Requery
            If Rs.BOF = True Then
                MsgBox "现在已经没有任何帐户档案记录", vbInformation, "帐户管理"
                For i = 0 To Controls.Count - 1
                    If TypeOf Controls(i) Is TextBox Then Controls(i).Text = ""
                Next
                Toolbar1.Buttons(3).Enabled = False
                List1.Clear
                Exit Sub
            End If
        End If
        Call fillList
        Exit Sub
    errorhandler:
       MsgBox Err.Number & "," & Err.Source & "," & Err.Description, vbInformation, "帐户管理"
       Unload Me
    Case "cancel"
        Rs.CancelUpdate
        On Error GoTo errorhandler_cancel
        Rs.MoveFirst
    errorhandler_cancel:
        If Rs.BOF = True Then
            For i = 0 To Controls.Count - 1
                If TypeOf Controls(i) Is TextBox Then
                    Controls(i).Enabled = False
                    Controls(i).Text = ""
                End If
            Next
            optMale.Enabled = False
            optFemale.Enabled = False
            cboMonth.Enabled = False
            cboDay.Enabled = False
            cboAccountTypeID.Enabled = False
            chkAtm.Enabled = False
            chkCheckbook.Enabled = False
            Call disallow
            Command1.Enabled = True
            Exit Sub
            Label16.Caption = "帐户余额"
        End If
        
        Call display
        For i = 0 To Controls.Count - 1
            If TypeOf Controls(i) Is TextBox Then Controls(i).Enabled = False
        Next
        optMale.Enabled = False
        optFemale.Enabled = False
        cboMonth.Enabled = False
        cboDay.Enabled = False
        cboAccountTypeID.Enabled = False
        chkAtm.Enabled = False
        chkCheckbook.Enabled = False
        Call disallow
        Command1.Enabled = True
        Label16.Caption = "帐户余额"
    Case "update"
        If Rs.BOF = True Then
            MsgBox "没有任何帐户档案记录,不能进行更新操作", vbInformation, "帐户管理"
            Toolbar1.Buttons(5).Enabled = False
            Exit Sub
        End If
        For i = 0 To Controls.Count - 1
            If TypeOf Controls(i) Is TextBox Then Controls(i).Enabled = True
        Next
        optMale.Enabled = True
        optFemale.Enabled = True
        cboMonth.Enabled = True
        cboDay.Enabled = True
        cboAccountTypeID.Enabled = True
        txtATMCardNumber.Enabled = False
        txtATMAccessCode.Enabled = False
        txtCheckBookNumber.Enabled = False
        txtStartNumber.Enabled = False
        txtEndNumber.Enabled = False
        txtID.Enabled = False
        txtAccountNumber.Enabled = False
        cboAccountTypeID.Enabled = False
        txtAccountBalance.Enabled = False
        Call allow
        Command1.Enabled = False
    Case "exit"
        Unload Me
    End Select
    End Sub