Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a table, query, field...

How To

Find a table, query, field...

by  hwkranger  Posted    (Edited  )

Code:
Public Function fFindField(strTableName, strFieldName As String, Optional cn As ADODB.Connection) As Boolean
    Dim rst As New ADODB.Recordset
    
    If cn Is Nothing Then
      Set cn = CurrentProject.Connection
    End If
  
    rst.Open cn.OpenSchema(adSchemaColumns, Array(Empty, Empty, strTableName, strFieldName))
    fFindField = Not rst.EOF
End Function

Public Function fFindTable(strTableName As String, Optional cn As ADODB.Connection) As Boolean
  Dim rs As ADODB.Recordset
  'Set cn = New ADODB.Connection
  If cn Is Nothing Then
    Set cn = CurrentProject.Connection
  End If
  
  Set rs = cn.OpenSchema( _
         adSchemaTables, Array(Empty, Empty, strTableName))
  fFindTable = Not rs.EOF
  rs.Close
  Set rs = Nothing
End Function

Public Function fFindAccessQuery(strQryName As String, Optional cn As ADODB.Connection) As Boolean
  'RETURNS TRUE ONLY IF THE QUERY IS AN ACCESS SELECT QUERY, WILL NOT RETURN ON PASS-THROUGHS
  Dim rs As ADODB.Recordset

  If cn Is Nothing Then
    Set cn = CurrentProject.Connection
  End If
  Set rs = cn.OpenSchema(adSchemaViews, Array(Empty, Empty, strQryName))
  fFindAccessQuery = Not rs.EOF
  rs.Close
  Set rs = Nothing
End Function
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top