[AccessD] Linking to various dbs through DAO /Access2k

Charlotte Foust cfoust at infostatsystems.com
Fri Apr 11 12:09:28 CDT 2003


Maybe the post lost something.  All I saw was an Attached attribute, not
AttachSavePwd.  I don't use password protected dbs, so I can't help you
there.  Here's a routine from my libraries that works to create a single
link.  I've removed the error handling, etc., for clarity, but maybe
this will help you get a handle on the problem.
 
Private Function LinkTable(ByVal strTblName As String, _
                          ByVal strTblAlias As String, _
                          ByVal strConnect As String)
  Dim dbs As DAO.Database
  Dim tdf As DAO.TableDef
  
  Set dbs = CurrentDb()
  Set tdf = dbs.CreateTableDef(strTblAlias)
  With tdf
    .Connect = strConnect
    .SourceTableName = strTblName
  End With
  dbs.TableDefs.Append tdf
  Set tdf = Nothing
  Set dbs = Nothing
ProcExit:
  Exit Function

End Function

 

Charlotte Foust

	-----Original Message-----
	From: Don Elliker [mailto:delliker at hotmail.com] 
	Sent: Friday, April 11, 2003 8:17 AM
	To: accessd at databaseadvisors.com
	Subject: RE: [AccessD] Linking to various dbs through DAO
/Access2k
	
	

	I have a front end which needs to attach to various BEs,
depending on the users requirement. The BE may or may not have the same
tables - so I cannot just reset the connect and refreshlink (I want all
the tables, regardless)  The database is also pword protected (not
secured) so I want to save the password (hence the Attribute
dbAttachSavePwd- the latest one I'm using - if I don't need it , great!
less work for mother). It does not like the append to the tabledefs
collection when the table is new.
	There are further strange things I have come across - it seems
that if the tabledef is 'nothing' you can still append it! It
mysteriously replaces an existing tabledef (probably ordinally)-so that
what it's named is not what it is. -don't think about it too much - it
hurts. I WILL solve this - any clues or thought gratefully accepted

	_d

	>From: "Charlotte Foust" 
	>Reply-To: accessd at databaseadvisors.com 
	>To: 
	>Subject: RE: [AccessD] Linking to various dbs through DAO
/Access2k 
	>Date: Fri, 11 Apr 2003 08:24:28 -0700 
	> 
	>You don't need to set an attached attribute if you create a
link. 
	>Access already knows it's attached. I don't understand what
you're 
	>doing. Is this the same BE you were already using or a
different one? 
	>Usually dropping and recreating a link is because you've
changed back 
	>ends but it sounds like you're doing something else. 
	> 
	>Charlotte Foust 
	> 
	>-----Original Message----- 
	>From: Don Elliker [mailto:delliker at hotmail.com] 
	>Sent: Friday, April 11, 2003 4:53 AM 
	>To: accessd at databaseadvisors.com 
	>Subject: RE: [AccessD] Linking to various dbs through DAO
/Access2k 
	> 
	> 
	> 
	> ok-tried that (it's commented) you can set the attributes if
you 
	>want btw. still fails on the append. I have some thoughts I
will try 
	>today and will advise. There's a cryptic note in the help about
the 
	>tables being appended when the Be is opened. I am doing a
delete of 
	>tabledefs prior to the attempt to append , that may be causing
me a 
	>problem. 
	> 
	> _d 
	> 
	> 
	> 
	> >From: "Charlotte Foust" 
	> >Reply-To: accessd at databaseadvisors.com 
	> >To: 
	> >Subject: RE: [AccessD] Linking to various dbs through DAO 
	>/Access2k 
	> >Date: Thu, 10 Apr 2003 14:21:31 -0700 
	> > 
	> >All you have to do is create the table and set its connect 
	>string and 
	> >sourcetable name, then append it to the TableDefs collection.

	>You don't 
	> >set attributes. 
	> > 
	> >Charlotte Foust 
	> > 
	> > -----Original Message----- 
	> > From: Don Elliker [mailto:delliker at hotmail.com] 
	> > Sent: Thursday, April 10, 2003 9:04 AM 
	> > To: accessd at databaseadvisors.com 
	> > Subject: [AccessD] Linking to various dbs through DAO 
	>/Access2k 
	> > 
	> > 
	> > 
	> > I am trying to get linked to a selected database through
code. 
	>I 
	> >get a failure on the append. The very informative 3251 
	>"Operation is not 
	> >supported for this type of object". I need to delete all the 
	>attached 
	> >tables and relink to new ones. 
	> > 
	> > I am doing this: db_Be is the new database I want to link
to. 
	> >dbcur is the front end I am running code from. 
	> > 
	> > Thanks, and How's everybody been?(don't answer that you'll 
	>kill 
	> >my hotmail account) 
	> > 
	> > _D 
	> > 
	> > For intI = 0 To db_BE.TableDefs.Count - 1 
	> > Set TdfBE = db_BE.TableDefs(intI) 
	> > SysCmd acSysCmdUpdateMeter, intI 
	> > If Not TdfBE.Name Like "msys*" Then 
	> > Set tdfNew = dbCur.CreateTableDef() 
	> > With tdfNew 
	> > .Name = "newtable" & intI 
	> > '.Attribu! tes = dbAttachedTable 
	> > .SourceTableName = TdfBE.Name 
	> > .Connect = "MS Access;DATABASE=" & 
	> >strDBName 
	> > End With 
	> > 'dbCur.TableDefs.Append (tdfNew) 
	> > 
	> > dbCur.TableDefs.Append (tdfNew) 
	> > ! End If 
	> > Next intI 
	> > 
	> > 
	> > 
	> > 
	> > _____ 
	> > 
	> > Tired of spam? Get advanced junk mail protection 
	> > with MSN 8. 
	> > 
	> >_______________________________________________ 
	> >AccessD mailing list 
	> >AccessD at databaseadvisors.com 
	> >http://databaseadvisors.com/mailman/listinfo/accessd 
	> >Website: http://www.databaseadvisors.com 
	> 
	> _____ 
	> 
	> Tired of spam? Get advanced junk mail protection 
	> with MSN 8. 
	> 
	>_______________________________________________ 
	>AccessD mailing list 
	>AccessD at databaseadvisors.com 
	>http://databaseadvisors.com/mailman/listinfo/accessd 
	>Website: http://www.databaseadvisors.com 

  _____  

	Help STOP SPAM with the new MSN 8
<http://g.msn.com/8HMDENUS/2731> and get 2 months FREE* 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030411/f68852af/attachment-0001.html>


More information about the AccessD mailing list