473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Split Database links

Sam
I have developed a small database which is setup with the front end and
backend files.

There are 12 linked tables withe the datafile located on our server.

Now the boss wants to be able to take a laptop offsite and still have
access, (even if read only) to the main data file (to be able to add records
in 1 table would also be useful).

I would like to be able to get the user to press a command button which
copies the data file into a local directory and updates the link paths for
the tables. This also incudes the linked images I have for the forms

I can handle getting information that is added back into the main file, just
the auto linking (user friendly) of the tables has me.

Any help?, I have looked at the code suggested on Allen Browne's tip site
but I can't see where that is going or how to adapt it to my use.

Regards

Sam
Nov 12 '05 #1
3 2999
Sam
Thanks for you comments Allen

have come up with something that looks like it should work but haven't
tried it, is it possible to see if I am heading in the right direction?

Code as follows (in General module, name Module 1)

Function CheckConnect()
Dim db As Database, strnetpath As String, srtlocalpath As String, strsource
As String
Dim strfile As String
Dim i As Integer

Set db = DBEngine.Workspaces(0).Databases(0)
strfile = "V3 Data.mdb"
strlocalpath = "C:\My Documents\"
strnetpath = "X:\AA PUBLIC FILES\Database\"
'check network path
If IsNull(Dir(strnetpath)) Then GoTo LocalPath
'else if db.path<> strnetpath then
For i = 0 To db.TableDefs.Count - 1
db.TableDefs(i).Connect = ";Database=" + strnetpath + strfile
db.TableDefs(1).RefreshLink
Next
End If
End

LocalPath:
MsgBox "Access has detected that the Network is Not Present" & Chr(13) &
"Press OK to Load Data From Local File", vbYesCancel

For i = 0 To db.TableDefs.Count - 1
db.TableDefs(i).Connect = ";Database=" + strlocalpath + strfile
db.TableDefs(1).RefreshLink
Next

End Function
Regards

Sam
"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:6j*******************@news-server.bigpond.net.au...
It's a matter of setting the Connect property of each TableDef, remembering to RefreshLink.

On startup, you want to see if the data file is available. Use Dir(). If
it's there, then loop through the TableDefs, and the non-system files that
have a Connect property that's different, set it to the network path.

If the Dir on the network back end fails, you probably want to pop up a
MsgBox() asking whether to use the local copy of the data. If the user
agrees, then set the Connect property to the local data file. You may also
want to modify the title bar of the application to show it's a local copy
not the real data that is being updated. Use
dbEngine(0)(0).Properties("AppTitle"), and Application.RefreshTitleBar.

Presumably you will store the usual network path in a table so you know
where to look again next startup.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Sam" <sa********@hotmail.com> wrote in message
news:Ck*******************@news-server.bigpond.net.au...
I have developed a small database which is setup with the front end and
backend files.

There are 12 linked tables withe the datafile located on our server.

Now the boss wants to be able to take a laptop offsite and still have
access, (even if read only) to the main data file (to be able to add

records
in 1 table would also be useful).

I would like to be able to get the user to press a command button which
copies the data file into a local directory and updates the link paths for the tables. This also incudes the linked images I have for the forms

I can handle getting information that is added back into the main file,

just
the auto linking (user friendly) of the tables has me.

Any help?, I have looked at the code suggested on Allen Browne's tip site but I can't see where that is going or how to adapt it to my use.

Regards

Sam


Nov 12 '05 #2
Yes, that's the general idea.

With each TableDef, check:
- it's name does not start with "MSYS" (the hidden system tables) or "~"
(deleted tables);
- it has a Connect property (i.e. you do not want to set it for locacl
tables).

There's a bit of debugging to do, e.g. you will need to use the MsgBox()
function (rather than statement) in the LocalPath code, and use an "i" (not
1) in the RefreshLink lines.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Sam" <sa********@hotmail.com> wrote in message
news:HR*******************@news-server.bigpond.net.au...
Thanks for you comments Allen

have come up with something that looks like it should work but haven't
tried it, is it possible to see if I am heading in the right direction?

Code as follows (in General module, name Module 1)

Function CheckConnect()
Dim db As Database, strnetpath As String, srtlocalpath As String, strsource As String
Dim strfile As String
Dim i As Integer

Set db = DBEngine.Workspaces(0).Databases(0)
strfile = "V3 Data.mdb"
strlocalpath = "C:\My Documents\"
strnetpath = "X:\AA PUBLIC FILES\Database\"
'check network path
If IsNull(Dir(strnetpath)) Then GoTo LocalPath
'else if db.path<> strnetpath then
For i = 0 To db.TableDefs.Count - 1
db.TableDefs(i).Connect = ";Database=" + strnetpath + strfile
db.TableDefs(1).RefreshLink
Next
End If
End

LocalPath:
MsgBox "Access has detected that the Network is Not Present" & Chr(13) &
"Press OK to Load Data From Local File", vbYesCancel

For i = 0 To db.TableDefs.Count - 1
db.TableDefs(i).Connect = ";Database=" + strlocalpath + strfile
db.TableDefs(1).RefreshLink
Next

End Function
Regards

Sam
"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:6j*******************@news-server.bigpond.net.au...
It's a matter of setting the Connect property of each TableDef,

remembering
to RefreshLink.

On startup, you want to see if the data file is available. Use Dir(). If
it's there, then loop through the TableDefs, and the non-system files that
have a Connect property that's different, set it to the network path.

If the Dir on the network back end fails, you probably want to pop up a
MsgBox() asking whether to use the local copy of the data. If the user
agrees, then set the Connect property to the local data file. You may also want to modify the title bar of the application to show it's a local copy not the real data that is being updated. Use
dbEngine(0)(0).Properties("AppTitle"), and Application.RefreshTitleBar.

Presumably you will store the usual network path in a table so you know
where to look again next startup.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Sam" <sa********@hotmail.com> wrote in message
news:Ck*******************@news-server.bigpond.net.au...
I have developed a small database which is setup with the front end and backend files.

There are 12 linked tables withe the datafile located on our server.

Now the boss wants to be able to take a laptop offsite and still have
access, (even if read only) to the main data file (to be able to add

records
in 1 table would also be useful).

I would like to be able to get the user to press a command button which copies the data file into a local directory and updates the link paths for the tables. This also incudes the linked images I have for the forms

I can handle getting information that is added back into the main
file, just
the auto linking (user friendly) of the tables has me.

Any help?, I have looked at the code suggested on Allen Browne's tip

site but I can't see where that is going or how to adapt it to my use.

Regards

Sam

Nov 12 '05 #3
1. Use error handling to recover.
If you don't know how to use error handling, see:
http://allenbrowne.com/ser-23a.html

2. Make sure you have excluded the system, temp, and local tables. Assign
the value to a string variable, and Debug.Print it to check it's okay. For
example the path needs the trailing slash. (You might also try the ampersand
for concatenation.)

3. Names of tables
Dim tdf As DAO.TableDef
For each tdf In db.TableDefs
If Left(tdf.Name, 4) = "MSys" ...

4. ???

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Sam" <sa********@hotmail.com> wrote in message
news:Jz*******************@news-server.bigpond.net.au...
Good to know I am on the right track, however the code that I have has a few errors
1. The line: If isnull(Dir(strnetpath)) Then GoTo LocalPath
gives an error (when logged off the server): Device not available
2. The line : db.TableDefs(i).Connect = ";Database=" +
strlocalpath + strfile also gives an error "Invalid operation"
3. You mentioned the system and hidden tables starting with msys and ~, I can't find a way to look at the start of a table name. I have no local
tables, so the need to not reconnect those is not required.
4. The Line I have in as a statement is like it is as I wanted to show I want to put the code there but havn't found how to write what I want it to
do (yet) ( 'else if db.path<> strnetpath then)
Any help, I am trying to brute force my way though learning the code but it seems like I have a long way to go!

Regards

Sam

"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:JR*******************@news-server.bigpond.net.au...
Yes, that's the general idea.

With each TableDef, check:
- it's name does not start with "MSYS" (the hidden system tables) or "~"
(deleted tables);
- it has a Connect property (i.e. you do not want to set it for locacl
tables).

There's a bit of debugging to do, e.g. you will need to use the MsgBox()
function (rather than statement) in the LocalPath code, and use an "i" (not
1) in the RefreshLink lines.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Sam" <sa********@hotmail.com> wrote in message
news:HR*******************@news-server.bigpond.net.au...
Thanks for you comments Allen

have come up with something that looks like it should work but haven't tried it, is it possible to see if I am heading in the right direction?
Code as follows (in General module, name Module 1)

Function CheckConnect()
Dim db As Database, strnetpath As String, srtlocalpath As String,

strsource
As String
Dim strfile As String
Dim i As Integer

Set db = DBEngine.Workspaces(0).Databases(0)
strfile = "V3 Data.mdb"
strlocalpath = "C:\My Documents\"
strnetpath = "X:\AA PUBLIC FILES\Database\"
'check network path
If IsNull(Dir(strnetpath)) Then GoTo LocalPath
'else if db.path<> strnetpath then
For i = 0 To db.TableDefs.Count - 1
db.TableDefs(i).Connect = ";Database=" + strnetpath + strfile db.TableDefs(1).RefreshLink
Next
End If
End

LocalPath:
MsgBox "Access has detected that the Network is Not Present" & Chr(13) & "Press OK to Load Data From Local File", vbYesCancel

For i = 0 To db.TableDefs.Count - 1
db.TableDefs(i).Connect = ";Database=" + strlocalpath + strfile db.TableDefs(1).RefreshLink
Next

End Function
Regards

Sam
"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:6j*******************@news-server.bigpond.net.au...
> It's a matter of setting the Connect property of each TableDef,
remembering
> to RefreshLink.
>
> On startup, you want to see if the data file is available. Use Dir(). If
> it's there, then loop through the TableDefs, and the non-system
files
that
> have a Connect property that's different, set it to the network
path. >
> If the Dir on the network back end fails, you probably want to pop up
a > MsgBox() asking whether to use the local copy of the data. If the
user > agrees, then set the Connect property to the local data file. You may also
> want to modify the title bar of the application to show it's a local

copy
> not the real data that is being updated. Use
> dbEngine(0)(0).Properties("AppTitle"), and Application.RefreshTitleBar. >
> Presumably you will store the usual network path in a table so you know > where to look again next startup.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
>
> "Sam" <sa********@hotmail.com> wrote in message
> news:Ck*******************@news-server.bigpond.net.au...
> > I have developed a small database which is setup with the front
end and
> > backend files.
> >
> > There are 12 linked tables withe the datafile located on our

server. > >
> > Now the boss wants to be able to take a laptop offsite and still

have > > access, (even if read only) to the main data file (to be able to add > records
> > in 1 table would also be useful).
> >
> > I would like to be able to get the user to press a command button

which
> > copies the data file into a local directory and updates the link paths for
> > the tables. This also incudes the linked images I have for the forms > >
> > I can handle getting information that is added back into the main

file,
> just
> > the auto linking (user friendly) of the tables has me.
> >
> > Any help?, I have looked at the code suggested on Allen Browne's tip site
> > but I can't see where that is going or how to adapt it to my use.
> >
> > Regards
> >
> > Sam



Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Larry L | last post by:
Access is noted for bloating a database when you add and delete records frequently. I have always had mine set to compact on close, and that works great. Now after everyone's advice I split my...
1
by: DD | last post by:
I have the following code and my question is Do i use a Autoexec to fire this ? As: fGetLinkedTables("ODBC") Or how do i ?? do i replace the above as fGetLinkedTables("test_be") Or ???
2
by: raydelex | last post by:
I have a split database (Access 2003). Now I need to port the database to the end-users' computer for a demonstration. When I try to start up the database on the other computer, it tells me...
7
by: nydiroth | last post by:
Our servers went down for over 6 hours yesterday and I was asked if there was a way to store the database on the server and a local station at the same time. My datbase is split and the tables...
1
by: QBCM | last post by:
We split our Access database as suggested with a front end application on local machines and back end tables on a data server. We need to add a field to one of the tables but it looks as if...
4
by: carriolan | last post by:
Hi I have managed to secure a split database. Both frontend and backend share a common workgroup, common security groups and common users and permissions, but as in all good stories there is a...
3
by: najimou | last post by:
Hi everyone I will be having a split database, running on 2 computers via mapped drive. computer "A" will have one front end and the back end located in c: \mydatabse 2 tables have links to...
4
by: Stan | last post by:
I am working on a database in ACCESS 2003. This is a simple DB with only one table. I have successfully split the database into database.mdb and database_be.mdb. When I copy the two files to a...
2
by: elgin | last post by:
I have a split Access 2003 database. I have signed the database with a Code Signing Certificate from Small Business Server. This works fine and users can have Access macro security on high or...
8
by: John Google | last post by:
Hi, I've been asked to amend an Access 2002 DB that has been used by users using the MDE version. I have, what seems to be the original MDB version containing all the front end stuff but, by...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.