Access从第10行开始导入特殊文本文件
quzbsc01_20.rar(2007-12-25 21:49:30, Size: 966 B , Downloads: 7)
''这是做好的函数Public Function Form_frmDataInto(Optional FileName As String = "")
On Error GoTo Err:
Dim FileNum As Long
Dim Temp As String
Dim varName As Variant
Dim strTemp As String
Dim i As Long
Dim m As Long
Dim TempFields As Variant ''字段
Dim TempValues As Variant ''值
Dim Conn As ADODB.Connection
Set Conn = CurrentProject.Connection
Dim strSQL As String
Dim rst As New ADODB.Recordset
If Len(FileName) = 0 Then FileName = CurrentProject.Path & "\QUZBSC01_11.028"
If MsgBox("确认要导入吗?", vbQuestion + vbYesNo) = vbNo Then Exit Function
strSQL = "SELECT top 1 * FROM 028"
rst.Open strSQL, Conn, adOpenKeyset, adLockOptimistic
Open FileName For Input As #
Line Input #1, Temp ' 读入一行数据并将其赋予某变量。
varName = Split(Temp, vbLf)
strTemp = ""
''获得字段
strTemp = varName(9)
TempFields = Split(strTemp, vbTab)
For i = 1 To UBound(TempFields)
Temp = TempFields(i)
Next
For i = 10 To UBound(varName) - 1
strTemp = varName(i)
TempValues = Split(strTemp, vbTab)
rst.AddNew
For m = 0 To UBound(TempFields)
rst(TempFields(m)) = TempValues(m)
rst.Update
Next
Close #1
rst.Close
Set rst = Nothing
Set Conn = Nothing
Err:
Debug.Print Err.Description
Close #1
Exit Function
end Function
end Function
(责任编辑:admin)
- ·关于 Partition 函数在分组查询中的应
- ·Access算术运算符的含义和说明表
- ·mid函数的另类用法
- ·access制作程序运行进度框
- ·Function与Sub的异同(函数调用)
- ·Access判断某个数值是否为某个数据类型
- ·select case后面语句块的值的四种格式
- ·vba条件语句的两种表示方法
- ·Access几种数据类型初始化的值
- ·Access vba null与""空字符串的区别
- ·access vba 数据类型表
- ·Access变量的命名规则
- ·Access中EXIT Sub与End Sub的区别
- ·Access vba中参数前关键字ByRef和ByVal
- ·Access列表框快速全选的技巧【最快】
- ·vba函数的数据类型强制转换