VBA/Excel/Access/Word/Application/Column Type
Версия от 19:33, 26 мая 2010; (обсуждение)
Changing the Value of an AutoNumber
<source lang="vb">
Sub ChangeAutoNumber()
Dim conn As ADODB.Connection Dim rst As ADODB.Recordset Dim strSQL As String Dim beginNum As Integer Dim stepNum As Integer Set conn = New ADODB.Connection conn.Open "Provider = Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & CurrentProject.Path & _ "\mydb.mdb" Set rst = New ADODB.Recordset With rst .CursorType = adOpenKeyset .LockType = adLockReadOnly .Open "Shippers", conn .MoveLast End With beginNum = rst(0) rst.MovePrevious stepNum = beginNum - rst(0) MsgBox "Last Auto Number Value = " & beginNum & vbCr & _ "Current Step Value = " & stepNum, vbInformation, _ "AutoNumber" rst.Close conn.Close Set conn = Nothing
End Sub
</source>
Listing Data Types
<source lang="vb">
Sub ListDataTypes()
Dim conn As ADODB.Connection Dim rst As ADODB.Recordset Set conn = New ADODB.Connection conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurrentProject.Path & "\mydb.mdb" Set rst = conn.OpenSchema(adSchemaProviderTypes) Do Until rst.EOF Debug.Print rst!Type_Name & vbTab _ & "Size: " & rst!Column_Size rst.MoveNext Loop rst.Close conn.Close Set rst = Nothing Set conn = Nothing
End Sub
</source>