473,387 Members | 1,569 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.

Checking linked tables on startup

tuxalot
200 100+
I've tested many ways to accomplish this, but none of the code I've found works quite right. I am using the code written by Dev Ashish but it replicates some of the functionality I already have. And, if you change the path to the back end manually and launch the db, Dev's code throws an error.

I think this request is fairly straightforward for someone experienced. I'm sure the code exists for this somewhere but I can't find it. Using Access 2007.

I have a split db setup and also another table that exists as a linked table. I've created forms (Form1, Form2) that allow an end user to change paths to these linked db's and this bit works fine. I have a startup form ready to accept code to check the following two items:

One of my linked back-end tables is called TblDepartment. I would like to check if this linked table exists and is accessible during startup. No need to iterate through all the tables, so I arbitrarily picked TblDepartment. If not-accessible, then open Form#1.

Next, the other stand alone linked mdb (not part of the BE db), has the same field names as one of my local tables and joins my main db via a union query. Again, I would like to check to see that this db is linked properly on startup. If not-accessible, then open Form#2.

As a side note, my db which I inherited from another developer has mixed references to DAO and ADODB. Would it be beneficial to change all code to one or the other?

Thanks for the look.
Mar 15 '09 #1
6 28843
ADezii
8,834 Expert 8TB
@tuxalot
I wrote this little code snippet for you. Hopefully, it should point you in the right direction. Any questions, please feel free to ask.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdTestLink_Click()
  2. On Error GoTo Err_cmdTestLink_Click
  3. Const conLINKED_TABLE As String = "tblDepartment"
  4.  
  5. 'A Linked Table will have a Connect Strain whose Length is > 0
  6. If Len(CurrentDb.TableDefs(conLINKED_TABLE).Connect) > 0 Then
  7.   'OK, we know that conLINKED_TABLE is a Linked Table, but is the Link valid?
  8.   'The next line of code will generate Errors 3011 or 3024 if it isn't
  9.   CurrentDb.TableDefs(conLINKED_TABLE).RefreshLink
  10.   'If you get to this point, you have a valid, Linked Table
  11.   '...normal code processing here
  12. Else
  13.   'An Internal Table will have a Connect String Length of 0
  14.   MsgBox "[" & conLINKED_TABLE & "] is a Non-Linked Table", vbInformation, "Internal Table"
  15. End If
  16.  
  17. Exit_cmdTestLink_Click:
  18.   Exit Sub
  19.  
  20. Err_cmdTestLink_Click:
  21.   Select Case Err.Number
  22.     Case 3265
  23.       MsgBox "[" & conLINKED_TABLE & "] does not exist as either an Internal or Linked Table", _
  24.              vbCritical, "Table Missing"
  25.     Case 3011, 3024     'Linked Table does not exist or DB Path not valid
  26.       MsgBox "[" & conLINKED_TABLE & "] is not a valid, Linked Table", vbCritical, "Link Not Valid"
  27.     Case Else
  28.       MsgBox Err.Description & Err.Number, vbExclamation, "Error in cmdTestLink_Click()"
  29.   End Select
  30.     Resume Exit_cmdTestLink_Click
  31. End Sub
Mar 15 '09 #2
tuxalot
200 100+
Spot on! Thanks ADezii.

Tux
Mar 15 '09 #3
tuxalot
200 100+
Actually if you manually change the path to the linked db and open the app, it throws a 3044 error. I added this to Err_cmdTestLink_Click and it works nicely.
Mar 15 '09 #4
ADezii
8,834 Expert 8TB
@tuxalot
Error Number 3044 is 'Application-defined or object-defined error' which hardly seems applicable in this case. Not that it really matters, but is there also some auxiliary code that you have not mentioned?
Mar 15 '09 #5
tuxalot
200 100+
Don't think so...where would I find the auxiliary code you are referring to?
Mar 15 '09 #6
ADezii
8,834 Expert 8TB
@tuxalot
Not importatnt, tuxalot, just getting side-tracked.
Mar 16 '09 #7

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

Similar topics

5
by: pinballjim | last post by:
Hello everyone, I'm looking for a simple way to create a local copy of a linked table. I've got a database that links about 10 tables from other databases. This works fine on my machine, but I...
2
by: Sam DeRT | last post by:
Is there a way to hard code what a path to a linked table would be without going through the Linked Table Manager or a re-linking process? My issue is that I'm installing a database with linked...
7
by: Joe | last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource (using Oracle ODBC drivers). After linking the tables in Access, I inspect the data contained in the linked tables. For...
2
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database,...
2
by: Andy | last post by:
Hello, I am working on an Access Application that uses Linked Tables to a SQL Server Backend. The problem I have is that there will be 2 types of users, one which will use a trusted connection and...
25
by: bubbles | last post by:
Using Access 2003 front-end, with SQL Server 2005 backend. I need to make the front-end application automatically refresh the linked SQL Server tables. New tables will be added dynamically in...
2
by: redpears007 | last post by:
Hi all, can anyone help me with this one? I have a database that has multiple linked tables and i want some code to tell the database on startup to do first check for the tables in a folder on...
18
by: afromanam | last post by:
Whew.. OK, running access 2003 in win xpsp2 and access 2007 in win vista. This is the question... We have a db, split in front end (FE.mdb) and backend (BE.mdb) FE has tons of linked...
7
by: Airtech | last post by:
I am building a media management tool and starting it in Access 2003. I have various linked tables, and have sufficient code to loop through my list of linked tables to verify that the data file...
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: 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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.