January 14
Sapendo come determinare il tipo di dati di un campo particolare in una tabella può rendere l'applicazione di database più dinamico. Microsoft Office Access è un sistema di gestione di database relazionali incluso nella suite Microsoft Office, spesso utilizzato per progettare database locali. Una query viene utilizzato per recuperare i dati da una tabella del database. Visual Basic, Applications, o VBA, è un linguaggio di programmazione utilizzato per automatizzare le attività di routine in Access e altre applicazioni di Microsoft Office.
1 Aprire il database Northwind di Microsoft Office Access. Il database Northwind è incluso nella suite Microsoft Office. Selezionare il menu "Inserisci" e fare clic su "Modulo".
2 Copia e incolla il seguente nel nuovo modulo a ciclo attraverso i campi della tabella "Dipendente" e visualizzare i loro tipi di dati:
getDataTypes Private Sub ()
Dim Varnum As Variant
Dim rst come Recordset
DBS fiochi come database
Dim fldCnt As Integer
Set dbs = CurrentDb
strSQL = "SELECT * FROM Employees Dipendenti;".
Set rst = dbs.OpenRecordset (strSQL)
Per fldCnt = 0 Per rst.Fields.Count - 1
varNum = rst.Fields(fldCnt).Type
Select Case Varnum
Case Is = dbBigInt
Debug.Print "Tipo dati è Big Integer"
Case Is = dbBinary
Debug.Print "Tipo dati è binario"
Case Is = dbBoolean
Debug.Print "Tipo dati è booleano"
Case Is = dbByte
Debug.Print "Tipo dati è Byte"
Case Is = dbChar
Debug.Print "Tipo dati è Char"
Case Is = dbCurrency
Debug.Print "Tipo dati è valuta"
Case Is = dbDate
Debug.Print "Tipo dati è Data / ora"
Case Is = dbDecimal
Debug.Print "Tipo dati è decimale"
Case Is = dbDouble
Debug.Print "Tipo dati è doppia"
Case Is = dbFloat
Debug.Print "Tipo dati è Float"
Case Is = dbGUID
Debug.Print "Tipo dati è Guid"
Case Is = dbInteger
Debug.Print "Tipo dati è Integer"
Case Is = dbLong
Debug.Print "Tipo dati è lungo"
Case Is = dbLongBinary
Debug.Print "Tipo dati è lungo Binary (Oggetto OLE)"
Case Is = dbMemo
Debug.Print "Tipo dati è appunto"
Case Is = DBNUMERIC
Debug.Print "Tipo di dati è numerico"
Case Is = dbSingle
Debug.Print "Tipo dati è unico"
Case Is = dbText
Debug.Print "Tipo dati è testo"
Case Is = dbtime
Debug.Print "Tipo di dati è il Tempo"
Case Is = DBTIMESTAMP
Debug.Print "Tipo dati è Time Stamp"
Case Is = dbVarBinary
Debug.Print "Tipo dati è VarBinary"
End Select
Successivo fldCnt
End Sub
3 Premere il tasto "F5" per eseguire la subroutine. I tipi di dati di campo alla tavola "Dipendente" verranno visualizzati attraverso la finestra immediata.