往GRID對應的RECORDSET插入數據。回車,在文本框之間跳轉,就不用說了吧。

解决方案 »

  1.   

    keydown事件中:
    if keycode=13 then
    text1(1).setfocus
    endif
      

  2.   

    这样还不如用mshflexgrid控件了
    Private Sub MSHF1_DblClick()
    On Error Resume Next
      Dim Response As String
      CurRow = MSHF1.Row - 1
      CurCol = MSHF1.Col - 1
      DE.rstd.MoveFirst
      DE.rstd.Move (CurRow)
      If CurCol = 3 Or CurCol = 4 Then
        Response = InputBox("请输入" & MSHF1.TextMatrix(0, CurCol + 1), "黄花菜", MSHF1.TextMatrix(CurRow + 1, CurCol + 1))
        If Len(Response) = 0 Then
        DE.rstd.Fields(CurCol) = MSHF1.TextMatrix(CurRow + 1, CurCol + 1)
        Else
        DE.rsutd.Fields(CurCol) = Response
        End If
      Else
        Response = InputBox("请输入" & MSHF1.TextMatrix(0, CurCol + 1), "黄花菜", MSHF1.TextMatrix(CurRow + 1, CurCol + 1))
        If Len(Response) = 0 Then
        DE.rstd.Fields(CurCol) = MSHF1.TextMatrix(CurRow + 1, CurCol + 1)
        Else
        DE.rstd.Fields(CurCol) = Val(Response)
        End If
      End If
      DE.rstd.Update
      Call Conn
    End SubSub Conn()
      MSHF1.Clear
      Set MSHF1.DataSource = DE.rstd
    End SubPrivate Sub MSHF1_EnterCell()
          '单击某一单元时,改变该行颜色
          Dim i_Col     As Integer
          Dim c_col     As Integer
          c_col = MSHF1.Col
          If c_col > 0 Then
                For i_Col = 0 To MSHF1.Cols - 1
                        MSHF1.Col = i_Col
                        MSHF1.CellBackColor = &HC0FFFF
                Next i_Col
                MSHF1.Col = c_col
          End If
      End Sub
      Private Sub MSHF1_LeaveCell()
          '当某一行失去焦点时,改变该行颜色
          Dim i_Col     As Integer
          Dim c_col     As Integer
          c_col = MSHF1.Col
          For i_Col = 0 To MSHF1.Cols - 1
                  MSHF1.Col = i_Col
                  MSHF1.CellBackColor = vbWhite
          Next i_Col
          MSHF1.Col = c_col
      End Sub