废话不多说,三张图就可以说明了:
有记录,字段有值:
有记录,字段为空:
新记录,尚未创建:
附这个窗体的源码:
Option Compare Database
Option Explicit
Private Sub Form_Load()
Msg.Enabled = True
Msg.Locked = False
Msg.Value = ""
Dim i As Byte
For i = 0 To 13
Msg.Value = Msg.Value & "As " & GetType(Me("f" & i).Value) & vbCrLf
Next i
Msg.Locked = True
Msg.Enabled = False
End Sub
Public Function GetType(var As Variant) As String
Select Case VarType(var)
Case vbEmpty
GetType = "vbEmpty"
Case vbNull
GetType = "vbNull"
Case vbInteger
GetType = "vbInteger"
Case vbLong
GetType = "vbLong"
Case vbSingle
GetType = "vbSingle"
Case vbDouble
GetType = "vbDouble"
Case vbCurrency
GetType = "vbCurrency"
Case vbDate
GetType = "vbDate"
Case vbString
GetType = "vbString"
Case vbObject
GetType = "vbObject"
Case vbError
GetType = "vbError"
Case vbBoolean
GetType = "vbBoolean"
Case vbVariant
GetType = "vbVariant"
Case vbDataObject
GetType = "vbDataObject"
Case vbDecimal
GetType = "vbDecimal"
Case vbByte
GetType = "vbByte"
Case vbUserDefinedType
GetType = "vbUserDefinedType"
Case vbArray
GetType = "vbArray"
Case Else
GetType = "TypeCode: " & VarType(var)
End Select
End Function
[此贴子已经被作者于2005-9-21 23:00:32编辑过]
|