NumericScale, Precision Properties Example

This example uses the NumericScale and Precision properties to display the numeric scale and precision of fields in the Discounts table of the Pubs database.

Public Sub NumericScaleX()

	Dim rstDiscounts As ADODB.Recordset
	Dim fldTemp As ADODB.Field
	Dim strCnn As String

	' Open recordset.
	strCnn = "driver={SQL Server};server=srv;" & _
		"uid=sa;pwd=;database=pubs"
	Set rstDiscounts = New ADODB.Recordset
	rstDiscounts.Open "discounts", strCnn

	' Display numeric scale and precision of
	' numeric and small integer fields.
	With rstDiscounts
		For Each fldTemp In .Fields
			If fldTemp.Type = adNumeric _
				Or fldTemp.Type = adSmallInt Then
				MsgBox "Field: " & fldTemp.Name & vbCr & _
					"Numeric scale: " & _
						fldTemp.NumericScale & vbCr & _
					"Precision: " & fldTemp.Precision
			End If
		Next fldTemp
		.Close
	End With
		
End Sub

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.