Option ExplicitDim db As Database'以下 Function 需要二个参数,sTable 是 Table 名称,sField 是字段名称 Function Getdescription(sTable As String, sField As String) As String Dim Sna As Recordset Dim i As Integer Dim existDescr As Boolean
Set Sna = db.OpenRecordset(sTable, dbOpenTable) existDescr = False For i = 0 To Sna(sField).Properties.Count - 1 If Sna(sField).Properties(i).Name = "Description" Then existDescr = True: Exit For End If Next If existDescr Then Getdescription = Sna(sField).Properties("Description") Else Getdescription = "" End If End FunctionPrivate Sub Command1_Click() Dim x As String MsgBox Getdescription("AABLE_L", "AABLE_LNO") End SubPrivate Sub Form_Load() Set db = opendatabase("c:\hris\ability.mdb") '数据库 End Sub 这是抓ACCESS的办法。
SELECT a.name AS 表名, b.name AS 字段, c.name AS 字段类型 FROM sysobjects a INNER JOIN syscolumns b ON a.id = b.id INNER JOIN systypes c ON b.xtype = c.xtype WHERE (a.name = 't_mobile') 把t_mobile替换成你想看的表名即可
Function Getdescription(sTable As String, sField As String) As String
Dim Sna As Recordset
Dim i As Integer
Dim existDescr As Boolean
Set Sna = db.OpenRecordset(sTable, dbOpenTable)
existDescr = False
For i = 0 To Sna(sField).Properties.Count - 1
If Sna(sField).Properties(i).Name = "Description" Then
existDescr = True: Exit For
End If
Next If existDescr Then
Getdescription = Sna(sField).Properties("Description")
Else
Getdescription = ""
End If
End FunctionPrivate Sub Command1_Click()
Dim x As String
MsgBox Getdescription("AABLE_L", "AABLE_LNO")
End SubPrivate Sub Form_Load()
Set db = opendatabase("c:\hris\ability.mdb") '数据库
End Sub
这是抓ACCESS的办法。
FROM sysobjects a INNER JOIN
syscolumns b ON a.id = b.id INNER JOIN
systypes c ON b.xtype = c.xtype
WHERE (a.name = 't_mobile')
把t_mobile替换成你想看的表名即可