One front end with multiple back ends

G

Guest

I have a database which is split front end/back end. When the user starts the
front end I want them to be prompted to select which back end to use. How do
I do this and then automatically link to the correct back end?
 
G

Guest

Assuming that all backend databases have the same tablenames, i would use a
combobox, perhaps linked to a table of database names (depending how many
there are) then use the following code snipet to re-link the tables in the
frontend;

Dim db As DAO.Database
Dim tdf As DAO.TableDef

Set db = CurrentDb

DoCmd.Echo True, "Refreshing table links..."

'for each attached table make sure it's attached to the correct data
source
For Each tdf In db.TableDefs
If Len(tdf.Connect) > 0 Then
If Left(tdf.Connect, 9) = ";DATABASE" Then
If Not tdf.Connect = ";DATABASE=" & gstrDataDBPath &
gstrDataDBName Then
tdf.Connect = ";DATABASE=" & gstrDataDBPath &
gstrDataDBName
tdf.RefreshLink
End If
End If
End If
Next tdf

'make sure to refresh the table definitions
db.TableDefs.Refresh

Where gstrDataDBPath & gstrDataDBName have been set to the relavant backend
path and name.
 
G

Guest

I am looking to do this exact thing but I am having problems. Where does the
code below go? I have created a form with a combo box to choose the path but
it is not doing anything. Can someone provide me with a little further
assistance? I would greatly appreciate it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top