回复 6楼 Artless
Option Explicit
Dim px As Boolean
Private Sub cmdFirst_Click() '第一条
Adodc1.Recordset.MoveFirst
Tongbu
End Sub
Private Sub cmdLast_Click() '最后一条
Adodc1.Recordset.MoveLast
Tongbu
End Sub
Private Sub cmdNext_Click() '下一条
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
Tongbu
End Sub
Private Sub cmdPrevious_Click() '上一条
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
Tongbu
End Sub
Private Sub cmdQue_Click()
Dim connstring As String
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\VB编程\familyIO.mdb;Persist Security Info=False"
Adodc1.ConnectionString = connstring
= adCmdText
Adodc1.RecordSource = "select * from out where '" & Combo1.Text & "'" & " like '" & gjzText.Text & "'"
DataGrid1.DataSource = Adodc1
Adodc1.Refresh
DataGrid1.Columns(1) = Adodc1.Recordset.Fields("1")
DataGrid1.Columns(2) = Adodc1.Recordset.Fields("2")
DataGrid1.Columns(3) = Adodc1.Recordset.Fields("3")
DataGrid1.Columns(4) = Adodc1.Recordset.Fields("4")
DataGrid1.Columns(5) = Adodc1.Recordset.Fields("5")
DataGrid1.Columns(6) = Adodc1.Recordset.Fields("6")
DataGrid1.Columns(7) = Adodc1.Recordset.Fields("7")
DataGrid1.Columns(8) = Adodc1.Recordset.Fields("8")
DataGrid1.Columns(9) = Adodc1.Recordset.Fields("9")
DataGrid1.Columns(10) = Adodc1.Recordset.Fields("10")
DataGrid1.Columns(11) = Adodc1.Recordset.Fields("11")
DataGrid1.Columns(12) = Adodc1.Recordset.Fields("12")
DataGrid1.Columns(13) = Adodc1.Recordset.Fields("13")
DataGrid1.Columns(14) = Adodc1.Recordset.Fields("14")
DataGrid1.Columns(15) = Adodc1.Recordset.Fields("15")
DataGrid1.Columns(16) = Adodc1.Recordset.Fields("16")
DataGrid1.Columns(17) = Adodc1.Recordset.Fields("17")
DataGrid1.Columns(18) = Adodc1.Recordset.Fields("18")
DataGrid1.Columns(0).Width = 500 '设置datagrid1控件列宽
DataGrid1.Columns(1).Width = 1000
DataGrid1.Columns(2).Width = 800
DataGrid1.Columns(3).Width = 600
DataGrid1.Columns(4).Width = 800
DataGrid1.Columns(5).Width = 600
DataGrid1.Columns(6).Width = 800
DataGrid1.Columns(7).Width = 600
DataGrid1.Columns(8).Width = 800
DataGrid1.Columns(9).Width = 600
DataGrid1.Columns(10).Width = 800
DataGrid1.Columns(11).Width = 600
DataGrid1.Columns(12).Width = 800
DataGrid1.Columns(13).Width = 600
DataGrid1.Columns(14).Width = 800
DataGrid1.Columns(15).Width = 600
DataGrid1.Columns(16).Width = 1000
DataGrid1.Columns(17).Width = 800
DataGrid1.Columns(18).Width = 800
If Adodc1.Recordset.EOF Then MsgBox "没有查找到结果!", , "查询提示"
End Sub
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
px = Not px
If px Then
Adodc1.Recordset.Sort = DataGrid1.Columns(ColIndex).DataField & " asc" '单击字段标题自动升序
Else
Adodc1.Recordset.Sort = DataGrid1.Columns(ColIndex).DataField & " desc" '单击字段标题自动降序
End If
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
Tongbu
End Sub
Private Sub Form_Load()
Dim connstring As String
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\VB编程\familyIO.mdb;Persist Security Info=False"
Adodc1.ConnectionString = connstring
= adCmdText
Adodc1.RecordSource = "select * from out where '" & Combo1.Text & "'" & " like '" & gjzText.Text & "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
Adodc1.Recordset.Sort = DataGrid1.Columns(1).DataField
Adodc1.Recordset.MoveLast
px = False
Combo1.AddItem ("日期")
Combo1.AddItem ("水果类")
Combo1.AddItem ("其他辅食类")
Combo1.AddItem ("生活用品类")
Combo1.AddItem ("衣物类")
Combo1.AddItem ("交通类")
Combo1.AddItem ("通信类")
Combo1.AddItem ("娱乐文化类")
Combo1.AddItem ("其他类")
DataGrid1.Enabled = False
'Combo1.ListIndex = 0
End Sub