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

How do I update a BE table with a UNC path?

Access 2007, split database, 9 users.

I have been able to link the BE tables with the Linked Table Manager. I use the UNC path because everyone has different drive mappings.

I can open my linked tables as a RecordSet and AddNew and Update records. However, I cannot Seek and Edit the linked tables. I understand that I need to open the BE tables directly in order to do this. (I have been told this is incorrect, but can't see how. As per the Microsoft Developer Reference, "You can't use the Seek method on a linked table because you can't open linked tables as table-type Recordset objects. However, if you use the OpenDatabase method to directly open an installable ISAM (non-ODBC) database, you can use Seek on tables in that database.")
Now, I can do a connection like this, and it works for me:

Expand|Select|Wrap|Line Numbers
  1. Dim dbs As DAO.Database 
  2. Set dbs = DBEngine.OpenDatabase("R:\Data\Task_be.accdb")
But, as I said, everyone has different drive mappings. Therefore, I need to use the Network address instead of a drive letter. I tried this:

Expand|Select|Wrap|Line Numbers
  1. Set dbs = DBEngine.OpenDatabase("\\Server\MyBackEnd\Data\Task_be.accdb")
This doesn't work. What am I doing wrong? Thanks.
Dec 12 '13 #1

✓ answered by NeoPa

May I suggest that it's probably the .Seek() method itself, rather than the table structure and design, that can more easily be dropped and replaced with another approach.

Using .Seek() is not the easiest approach anyway, and only works for local tables anyway. If you use the .Find...() methods instead you should find it a lot more straightforward.

6 2277
NeoPa
32,556 Expert Mod 16PB
May I suggest that it's probably the .Seek() method itself, rather than the table structure and design, that can more easily be dropped and replaced with another approach.

Using .Seek() is not the easiest approach anyway, and only works for local tables anyway. If you use the .Find...() methods instead you should find it a lot more straightforward.
Dec 12 '13 #2
zmbd
5,501 Expert Mod 4TB
This will take care of remapping your linked tables:

The following is part of a much larger section of code.
This is part of my "universal" backend reconnect code that I use in my splash-screen/form.
It first checks for the exsistance of the backend in the last known location (simple len(dir()) type check) if that holds true then I test that I can read from the table for version information, if there's a connection error, then I run the following code...

If the LKL of the BE fails, then I open a folder picker that is a variation on a theme as found here: Select a File or Folder using the FileDialog Object build a string with the path and pass it to the following code...

Expand|Select|Wrap|Line Numbers
  1. '>>>CODE OMITTED:\
  2. on error goto zerrortrap:
  3. '
  4. Set zdb = CurrentDb
  5. '(...)
  6. For Each ztdf In zdb.TableDefs
  7.     If ztdf.Attributes = dbAttachedTable Then
  8.         ztdf.Connect = ";DATABASE=" & zpath & ";TABLE=" & ztdf.SourceTableName
  9.         ztdf.RefreshLink
  10.         If Err.Number > 0 Then Err.Clear
  11.     End If
  12. Next
  13. '(...)
  14.  
I have a few error checks involved so that if any of the connections fail a message is generated and the local frontend has a table where all of this is recorded for troubleshooting.

and there you have it.

As for the .seek()... that is a much larger issue... use the .find() instead.
Dec 12 '13 #3
Thank you NeoPa. I will give .Find a try. It sounds like the right thing for me.
As for the error checking, zmbd, I have been a foolish novice in this area. I need to add all kinds of checks. Once I get my update code working, I'll put in a splash screen and some basic checking. Thanks for the sage advice.
Dec 12 '13 #4
zmbd
5,501 Expert Mod 4TB
Marvin, sometimes, I don't usually enable my error checks until I'm well into the alpha and often just before I go beta as I often need the compiler to choke at the offending line in order to fix.
Dec 12 '13 #5
You guys were right. I first tried using Database.Execute "UPDATE SQL statement string" as suggested on another board. I kept getting errors in my SQL statement. Then I did a test on a small table with Recordset.FindFirst and it works. Here's a snippet:

Expand|Select|Wrap|Line Numbers
  1. Dim strRec As String
  2. Dim db As Database
  3. Dim rs As DAO.Recordset
  4.  
  5. strRec = RecNum.Value
  6.  
  7. Set db = CurrentDb
  8. Set rs = db.OpenRecordset("tblStatus")
  9.  
  10. With rs
  11.     .FindFirst "Rec_Num = " & strRec & " And Stat_Cd = 'O'"
  12.     .Edit
  13.     !Current_Ind = False
  14.     .Update
  15. End With
This finds one record with a Status Code of 'O' and turns off the Current Indicator flag. What I want to do next is change that condition to <>'A' where it may have more than one record to change. Then between .Edit and .Update, I'll put in a Do While loop that will .FindNext and change the flag for every record. (This is not a mass operation. If there is ever more than one to change it will only be 2 or 3. I just want to have a catch all.)

So to wrap up this thread for anyone who finds it in the future... The solution to the initial question is NOT to do the update through the UNC path as I was trying to do, but to re-examine the way that the update is done. It is possible to make updates by way of a recordset to a linked table. Use the FindFirst method instead of Seek.

Thank you, Experts!
Dec 12 '13 #6
NeoPa
32,556 Expert Mod 16PB
Very pleased to hear that everything worked out with a little helpful advice. Z's comments about error catching is also well worth following. It's very easy to miss logic errors if you trap the code errors.
Dec 13 '13 #7

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

Similar topics

2
by: amwi | last post by:
I have tried to solve this on my own for a long time now, so i really need some help here... I use Oracle 10.1 and SQL *plus 10.1. How do i update table a.fkid from table b.pkid with the...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
9
by: baonks | last post by:
hello all here is my problem: I have 2 table 1: K_POS SALDO_A_D SALDO_A_K 11100 105 5 11200 5 105
2
by: Ron | last post by:
Hello, I am trying to do a simple update on employee information. I am a novice at both aspx and SQLServer, so I hope you are not too offended by my code. The following is the update code: ...
2
by: Paul712 | last post by:
Recently, I have a table that I use to update a master table. When I run the same Update query that's been successful in the past, most all of the data in the fields in the update fields has been...
0
by: jainapurva108 | last post by:
Hi, I have one table with some values as shown in below format... Column-A Column-B Column-C Column-D Column-E 11AA ------ 1234 ------ ASDF------ FIRST ------ONE 22BB ------ ...
5
by: SQL Learner | last post by:
Hi Alex (Kuznetsov) and All, This is to follow up with my last post, "Link two tables using partial word match". How can I UPDATE table using partial word match? How can I write a SQL statement...
1
by: mrobinsc | last post by:
** This SQL statement returns 4 rows SELECT COUNT(*) G.ACTIVITY_ID G.RESOURCE_TYPE G.RESOURCE_CATEGORY G.RESOURCE_SUB_CAT G.ANALYSIS_TYPE G.PROJECT_ID
1
by: adithi | last post by:
My Table Structure is: Table A Table B Table C colA -PK Col B-PK Col C-PK Col B-FK ...
8
stonward
by: stonward | last post by:
Greetings All. I am trying to find the syntax for an SQL Update Table instruction. They're quite straightforward it seems until you try to use variables as criteria. So, I want to update the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.