PC Review


Reply
Thread Tools Rate Thread

Anything obviously wrong with this code?

 
 
Chris K
Guest
Posts: n/a
 
      12th Aug 2010
I am designing a split database + I'm moving from one machine to another and
linked tables only support absolute addressing

So I wrote some code in the front end form to link the table in the back end
(one at the mo) which is always in the same directory

Private Sub Form_Load()
Dim tbl As TableDef
For Each tbl In CurrentDb.TableDefs
If (tbl.Attributes And dbSystemObject) = 0 _
Then tbl.Connect = ";DATABASE=" & CurrentProject.path &
"\JHP_be.mdb": tbl.RefreshLink
Next
..........
..........

I wrote this few years ago and it worked perfectly - I used the same code on
more recent database and it works most of the time but sometimes has trouble
connecting and I cant imagine why?

Anything obviously wrong with this code?

 
Reply With Quote
 
 
 
 
Stuart McCall
Guest
Posts: n/a
 
      12th Aug 2010
"Chris K" <(E-Mail Removed)> wrote in message
news:Q3Y8o.96437$Y21.42545@hurricane...
>I am designing a split database + I'm moving from one machine to another
>and linked tables only support absolute addressing
>
> So I wrote some code in the front end form to link the table in the back
> end (one at the mo) which is always in the same directory
>
> Private Sub Form_Load()
> Dim tbl As TableDef
> For Each tbl In CurrentDb.TableDefs
> If (tbl.Attributes And dbSystemObject) = 0 _
> Then tbl.Connect = ";DATABASE=" & CurrentProject.path &
> "\JHP_be.mdb": tbl.RefreshLink
> Next
> .........
> .........
>
> I wrote this few years ago and it worked perfectly - I used the same code
> on more recent database and it works most of the time but sometimes has
> trouble connecting and I cant imagine why?
>
> Anything obviously wrong with this code?


VBA sometimes gets a bit twitchy when you use single-line If...Then
statements broken over multiple lines. Try this:

Dim tbl As TableDef
For Each tbl In CurrentDb.TableDefs
If (tbl.Attributes And dbSystemObject) = 0 Then
tbl.Connect = ";DATABASE=" & CurrentProject.path & "\JHP_be.mdb"
tbl.RefreshLink
End If
Next



 
Reply With Quote
 
Chris K
Guest
Posts: n/a
 
      13th Aug 2010


"Stuart McCall" <(E-Mail Removed)> wrote in message
news:TOY8o.145979$zo4.108868@hurricane...
> "Chris K" <(E-Mail Removed)> wrote in message
> news:Q3Y8o.96437$Y21.42545@hurricane...
>>I am designing a split database + I'm moving from one machine to another
>>and linked tables only support absolute addressing
>>
>> So I wrote some code in the front end form to link the table in the back
>> end (one at the mo) which is always in the same directory
>>
>> Private Sub Form_Load()
>> Dim tbl As TableDef
>> For Each tbl In CurrentDb.TableDefs
>> If (tbl.Attributes And dbSystemObject) = 0 _
>> Then tbl.Connect = ";DATABASE=" & CurrentProject.path &
>> "\JHP_be.mdb": tbl.RefreshLink
>> Next
>> .........
>> .........
>>
>> I wrote this few years ago and it worked perfectly - I used the same code
>> on more recent database and it works most of the time but sometimes has
>> trouble connecting and I cant imagine why?
>>
>> Anything obviously wrong with this code?

>
> VBA sometimes gets a bit twitchy when you use single-line If...Then
> statements broken over multiple lines. Try this:
>
> Dim tbl As TableDef
> For Each tbl In CurrentDb.TableDefs
> If (tbl.Attributes And dbSystemObject) = 0 Then
> tbl.Connect = ";DATABASE=" & CurrentProject.path & "\JHP_be.mdb"
> tbl.RefreshLink
> End If
> Next
>
>


Ill give that a try thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wrong syntax when I try to set Javascript code in C# Code Behind. mesut Microsoft C# .NET 5 30th Jul 2008 10:22 AM
can some tell me what's wrong with this code? BRC Microsoft Access Form Coding 6 28th Jun 2007 11:19 PM
HREF ASP code problem - what's wrong with this code.... =?Utf-8?B?TWljaw==?= Microsoft Frontpage 3 14th Nov 2005 01:53 PM
Re: what is wrong with this code =?Utf-8?B?TWlrZQ==?= Microsoft ASP .NET 0 16th Sep 2004 09:13 PM
If IsNull Check Number Stop Code, What is wrong with this code ? Dave Elliott Microsoft Access Forms 1 21st Dec 2003 03:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:44 PM.