VBA/Excel/Access/Word/Application/Column Type

Материал из VB Эксперт
Версия от 12:46, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Changing the Value of an AutoNumber

 
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



Listing Data Types

 
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