473,387 Members | 1,515 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,387 software developers and data experts.

Unlinking and relinking a back end table

204 128KB
In a multi-user environment I want a user to be able to unlink a table from the back end so he can make temporary changes to the table without interfering with other users. But most of the time the table should stay linked so he can get the latest data.

I figured I can unlink the table with
Expand|Select|Wrap|Line Numbers
  1. If Len(CurrentDB.TableDefs("Walks").Connect)>0 Then
  2.    DoCmd.DeleteObject acTable,"Walks"
  3. End If
  4.  
After fiddling with the table the user will log out and any changes he makes can be discarded. But I suspect I'll have to re-link the table before closing the DB so that he'll get the latest version next time he opens it. This is a bit of a challenge - most of the "Relink" stuff I've seen on the net assumes the table is currently linked and just needs to be shifted to a different BE table. Will the Relink code work if the table is not currently linked at all? I've also seen code which loops through all the tables in the application and links them, but I'm not quite sure how to apply it to just the "Walks" table.
Any suggestions will be much appreciated.
Jul 25 '17 #1
3 3086
PhilOfWalton
1,430 Expert 1GB
Peter.

That is a really bad idea. Users should NEVER have access to tables in design view especially in a multi-user environment.

Think what happens if they delete a field. I certainly wouldn't know how to recover the data.

Why on earth do you want to do this?

Phil
Jul 25 '17 #2
Petrol
204 128KB
No, I wasn't thinking of giving him access to a table in design view. I want to be able to programmatically disassociate his copy from the master copy that others access.

There are several forms and reports which can update or display information about a particular Walk. The Registrar will need to work on one forthcoming Walk over a period of weeks, and doesn't want to have to keep re-specifying which Walk every time. So the Walks table contains a field indicating which of the 100 or so Walks is currently selected for subsequent forms or reports to act on.

But other people can have access to just one of those reports, which displays information about the selected Walk. Unfortunately I can't give him a read-only access to the database - Access doesn't work that way - so I give him access to only that report. However he also needs to be able to select the Walk he wants to report on. That involves setting the "Selected" field for that Walk in the Walks table. But I don't want that to muck up what the Registrar or others may be doing with other Walks.

Apart from the "Selected" field, the Walks table only rarely changes, so the restricted user doesn't need it to be updated in real time. Since each user has their own copy of the FE on their own computer, which accesses a common copy of the BE, the simplest solution seems to be for the restricted user to drop the link to the Walks table so he can select the Walk on his own machine. I just want the "Select Walk" facility to quietly unlink his table - he won't even know about it.

Actually, now that I come to think about it, I probably don't need to relink the table when he closes the DB. The batch file on each user's computer which invokes the FE actually copies it afresh from the cloud each time, so that when I deploy a new version everybody will get it. So they'll all get a fresh set of linked tables anyway. It just seemed aesthetically wrong to leave the table unlinked. What do you think?

I can easily pick up the Connect string from one of the other tables that never gets unlinked:
Expand|Select|Wrap|Line Numbers
  1. CurrentDB.TableDefs("Walks").Connect = CurrentDB.TableDefs("Talks").Connect
All I needed was a command to reverse the effect of the DeleteObject command. But perhaps I don't need it after all?
Jul 25 '17 #3
PhilOfWalton
1,430 Expert 1GB
A much better solution would be to set up a user table with an indicator as to whether that user has edit or read only permissions.
Then set up a JoinUserWalk table with UserID, WalkID as combined primary key and Selected as a yes/no field. This allows any user a limited no of walks he has access to, and by default will bring up only the Walk that user is interesed in.

If you don't want a user to log in, you can use the computer name instead.
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Declare Function apiGetComputerName Lib "kernel32" Alias _
  5.     "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  6.  
  7. Function fOSMachineName() As String
  8.     'Returns the computername
  9.  
  10.     Dim lngLen As Long, lngX As Long
  11.     Dim strCompName As String
  12.  
  13.     lngLen = 16
  14.     strCompName = String$(lngLen, 0)
  15.     lngX = apiGetComputerName(strCompName, lngLen)
  16.     If lngX <> 0 Then
  17.         fOSMachineName = Left$(strCompName, lngLen)
  18.     Else
  19.         fOSMachineName = ""
  20.     End If
  21.  
  22. End Function
  23.  
  24. Function ComputerName() as String
  25.     Dim ComputerName As String
  26.  
  27.     ComputerName = fOSMachineName()         ' This computer name
  28.  
  29. Exit Function
  30.  
So the main form for the walks also has the 2 new tables in the RecordSource, and if the user does not have edit privileges, then lock all the controls (text box, combo & list box using a loóp) then unlock your Combo Box to select a different Walk.

A bit of code to set the Selected indicator for that user in the JoinUserWalk table and unset the indicator for all the other walks for that User only.

Phil
Jul 26 '17 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ray | last post by:
I have a split DB running on a network, with code to relink to tables on launch of the client is they are broken. Usually, this works fine, but for some reason just hangs if another user is...
3
by: DS | last post by:
How do you unlink tables in a split database. Or change the link? Thanks DS
1
by: Zlatko Matić | last post by:
Is there any common method for programatical relinking of linked tables?
2
by: Mike MacSween | last post by:
My clients are replacing their file server. Their application is the standard FE on each workstation, BE on the server. The transition to the new server may or may not go smoothly. At the moment...
23
by: cmd | last post by:
I use the following code (behind a command button on the FE) to relink from a user's local copy of the BE to the file-server's BE on our LAN. I use this, for example, when a person brings in their...
4
by: Owen Jenkins | last post by:
Hi, No-one replied to this when I sent it last week. Any bites out there today?? ----- My application allows users to create a new back end for separate purposes. It does this by using Make...
13
by: Arno R | last post by:
Hi all, I am deploying an A2k app to users with different versions of Access. Using Access 2000 the relinking on startup (on deploying a new frontend or when backend has changed) is very fast....
14
by: jehugaleahsa | last post by:
Hello: I am working with Oracle .NET Stored Procedures. I would like to know how to return the results of a SELECT statement. I have tried returning a OracleRefCursor and a DataTable, but...
2
by: Murdz | last post by:
Hi. Pulling back table information is easy enough; SELECT * FROM information_schema.tables WHERE TABLE_NAME = 'pubs' However, I want a stored proc to be able to pull back all data from...
1
twinnyfo
by: twinnyfo | last post by:
A long-understood, good practice for Database design is to “split” the database into a Front End (FE) and a Back End (BE). The FE contains all the Queries, Forms, Reports and Modules needed to make...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.