INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How To

Find a table, query, field... by hwkranger
Posted: 9 Jan 07


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

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close