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

Link a Table through VBA by hwkranger
Posted: 9 Jan 07


CODE

Public Function LinkTable(strLocalName As String, strSourceName As String, strSourceLocation As String, blnHideTable as boolean)
'Links a table to the current project
If fFindTable(strLocalName) Then
    DoCmd.DeleteObject acTable, strLocalName
End If
    DoCmd.TransferDatabase acLink, "Microsoft Access", strSourceLocation, acTable, strSourceName, strLocalName
    
    Dim tb As New ADOX.Table
    Dim cat As New ADOX.Catalog
    
    cat.ActiveConnection = CurrentProject.Connection
    Set tb = cat.Tables(strLocalName)
    tb.Properties("Jet OLEDB:Table Hidden In Access") = blnHideTable
    
End Function

Requires:

CODE

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

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