Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 30th, 2009, 10:42 AM
benign benign is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 62 benign User rank is Lance Corporal (50 - 100 Reputation Level)benign User rank is Lance Corporal (50 - 100 Reputation Level)benign User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 16 h 20 m 23 sec
Reputation Power: 2
Importing backend automatically with VBA

For a database being used in different offices, I want to provide a config page within the DB App itself so that the user can specify a custom path for the database backend for linking.

I've been messing around with it and am able to link to a backend, if I specify in vba the table names from the back end. I'd rather not do this.

I'm also able to load the backend (importing it, it seems) through VBA. If I check the tables for a connect status, it says it's zero, which is what I get if the tables are not linked.

What I want to do is use VBA to link every table in the backend without having to know the names of the tables.

If I try to do a for loop for each tbl.name after loading the database with :

'Set wrkAcc = CreateWorkspace("", "admin", "", dbUseJet)
'Set dbs = wrkAcc.OpenDatabase("C:\testdatabase_be.accdb")

It doesn't seem to want to work. I suppose I need a way to get each table name before linking all the tables with code such as:

Code:
Dim tdf As TableDef
Dim strSourceName As String
Dim strLocalName As String 
Dim strSourceDatabase As String

With CurrentDb
Set tdf = .CreateTableDef(strLocalName)
tdf.SourceTableName = strSourceName
tdf.Connect = ";DATABASE=" & strSourceDatabase
.TableDefs.Append tdf
.Close
End With


... but with the above, the database is never loaded/read to get the names so tables must be known; however, when I do load (import?) the database, I can't import the tables as such.

I think I need to open the database, get the names, close it (doesn't seem to be the right word) and then use that info to start linking it.

Any suggestions?

Reply With Quote
  #2  
Old October 30th, 2009, 12:41 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 1,081 June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 14 h 55 m 48 sec
Reputation Power: 225
Are these users accessing the same backend stored on a network server? Use UNC (Universal Naming Convention) to link tables then distribute the frontend to users. This method refers to the server name in directory path. Must use code to set the links. Here is example from my project. Fritz is the server name.
Code:
Public Sub NormalizeTableLinks()
'Easier relinking of tables when cases are different in paths, etc.
'Use the variables provided to do the manipulations desired

Dim td As TableDef
Dim db As DAO.Database
Dim strOld As String
Dim strNew As String

'replace the following strings as needed
strOld = "M:\Data\LabData.accdb"
strNew = "\\Fritz\admin\Materials Lab\Lab Database\Data\LabData.accdb"
'strOld = "M:\Data\DBASE"
'strNew = "\\Fritz\admin\Materials Lab\Lab Database\Data\DBASE"

Set db = CurrentDb

For Each td In db.TableDefs
    If InStr(td.Connect, strOld) > 0 Then
        Debug.Print td.Name
        Debug.Print "Old Link: " & td.Connect
        td.Connect = Replace(td.Connect, strOld, strNew)
        td.RefreshLink
        Debug.Print "New Link: " & td.Connect
    End If
Next td

db.TableDefs.Refresh

End Sub
If each user is getting their own backend then this does not apply.

Last edited by June7 : October 30th, 2009 at 12:44 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Importing backend automatically with VBA


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek