主要的代码如下,完整的数据就不好放了,不好意思啊 ***************************** Public cN As New ADODB.Connection Public rD As New ADODB.Recordset Public Sqlstr As String --------------------------------------- Sub main() ThisWorkbook.Sheets("录入").Activate cN.CursorLocation = adUseClient cN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ThisWorkbook.Path & "/" & ThisWorkbook.Name & " ;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""" Sqlstr = "select * from [回款人$] order by 账号" rD.Open Sqlstr, cN, adOpenKeyset, adLockOptimistic setGw mfrm.Show End Sub ************************************* 主要的功能在这个模块:输入框每输入一个字符,就查询匹配的,直到查询到唯一的一个为止 每个账号正常情况下应该录入七到八个数字就可以查到唯一确认的一个账号 所以每个账号录入要查询七八次,然后我每天要录入近千个账号,所以查询量是巨大的 Private Sub TextBox1_Change() Dim tempA As String tempA = Trim(TextBox1.Text) If tempA = "" Then Sqlstr = "select * from [回款人$] order by 账号" Else Sqlstr = "select * from [回款人$] where 账号 like '" & tempA & "%' order by 账号" End If rD.Close Set rD = Nothing rD.Open Sqlstr, cN, adOpenKeyset, adLockOptimistic setGw End Sub *********************************************************** Public Sub setGw() Set mfrm.DataGrid1.DataSource = rD mfrm.DataGrid1.Columns(0).Width = 30 mfrm.DataGrid1.Columns(1).Width = 120 mfrm.DataGrid1.Columns(2).Width = 120 mfrm.DataGrid1.Columns(3).Width = 120 End Sub ********************************************
[此贴子已经被作者于2007-1-26 18:13:15编辑过] |