|
- Private Sub Command0_Click()
- ' getTblName "日期"
-
- MsgBox IsFldNameExist("订单列表", "日期")
-
- End Sub
- Sub getTblName(strFiledName As String)
- Dim tbl As DAO.TableDef
- Dim rs As DAO.Recordset
- Dim i As Integer
- Dim strtblName As String
- On Error Resume Next
- For Each tbl In CurrentDb.TableDefs
- If Left(tbl.Name, 4) <> "Msys" And Left(tbl.Name, 1) <> "~" Then
- Set rs = CurrentDb.OpenRecordset(tbl.Name)
- For i = 0 To rs.Fields.Count - 1
- If rs.Fields(i).Name = strFiledName Then
- strtblName = strtblName & tbl.Name & ";"
- Exit For
- End If
- Next
- rs.Close
- End If
- Next
- MsgBox strtblName
- Set rs = Nothing
- Set tbl = Nothing
- End Sub
- Public Function IsFldNameExist(tblName As String, fldName As String) As Boolean
- Dim rs As New ADODB.Recordset
- Dim i As Integer
- rs.Open tblName, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
- For i = 0 To rs.Fields.Count - 1
- If rs.Fields(i).Name = fldName Then
- IsFldNameExist = True
- Exit For
- End If
- Next
- rs.Close
- Set rs = Nothing
- End Function
复制代码 |
|