PC Review


Reply
Thread Tools Rate Thread

Connect to a back end in code

 
 
Chris K
Guest
Posts: n/a
 
      16th Aug 2010
I'm using code in a form open event to connect to back end table


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 used this before without a problem but I keep getting errors this time

I cant help wonder whether the code is OK (always was before) and I'm just
not running it early enough

Is there anyway I can run this code upon start up (not wait until the form
opens on start up)

 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      16th Aug 2010
Knowing the errors would definitely help people...

If the form is bound, then yes, the Load event it too late: try the Open
event instead. Your best bet, though, might be to have an unbound form as
your Startup form, and put the code in it (either Open or Load should work)

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele
Co-author: "Access 2010 Solutions", published by Wiley
(no e-mails, please!)



"Chris K" <(E-Mail Removed)> wrote in message
news:ESfao.110007$qO1.71499@hurricane...
> I'm using code in a form open event to connect to back end table
>
>
> 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 used this before without a problem but I keep getting errors this time
>
> I cant help wonder whether the code is OK (always was before) and I'm just
> not running it early enough
>
> Is there anyway I can run this code upon start up (not wait until the form
> opens on start up)


 
Reply With Quote
 
Chris K
Guest
Posts: n/a
 
      16th Aug 2010
The error varies "JHPmain (form recordsource) does not exist" - sometimes
"Disk Error"

Tried it in Form Open and still errors

I found my old database with same routine in Form Load and it connects all
five table without issue

I dont get it

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
news:i4c8fd$n70$(E-Mail Removed)...
> Knowing the errors would definitely help people...
>
> If the form is bound, then yes, the Load event it too late: try the Open
> event instead. Your best bet, though, might be to have an unbound form as
> your Startup form, and put the code in it (either Open or Load should
> work)
>
> --
> Doug Steele, Microsoft Access MVP
> http://www.AccessMVP.com/djsteele
> Co-author: "Access 2010 Solutions", published by Wiley
> (no e-mails, please!)
>
>
>
> "Chris K" <(E-Mail Removed)> wrote in message
> news:ESfao.110007$qO1.71499@hurricane...
>> I'm using code in a form open event to connect to back end table
>>
>>
>> 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 used this before without a problem but I keep getting errors this time
>>
>> I cant help wonder whether the code is OK (always was before) and I'm
>> just not running it early enough
>>
>> Is there anyway I can run this code upon start up (not wait until the
>> form opens on start up)

>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      18th Aug 2010
Perhaps you should show the code you're using then.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele
Co-author: "Access 2010 Solutions", published by Wiley
(no e-mails, please!)



"Chris K" <(E-Mail Removed)> wrote in message
news:t0jao.13129$2b4.9491@hurricane...
> The error varies "JHPmain (form recordsource) does not exist" - sometimes
> "Disk Error"
>
> Tried it in Form Open and still errors
>
> I found my old database with same routine in Form Load and it connects all
> five table without issue
>
> I dont get it
>
> "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
> news:i4c8fd$n70$(E-Mail Removed)...
>> Knowing the errors would definitely help people...
>>
>> If the form is bound, then yes, the Load event it too late: try the Open
>> event instead. Your best bet, though, might be to have an unbound form as
>> your Startup form, and put the code in it (either Open or Load should
>> work)
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://www.AccessMVP.com/djsteele
>> Co-author: "Access 2010 Solutions", published by Wiley
>> (no e-mails, please!)
>>
>>
>>
>> "Chris K" <(E-Mail Removed)> wrote in message
>> news:ESfao.110007$qO1.71499@hurricane...
>>> I'm using code in a form open event to connect to back end table
>>>
>>>
>>> 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 used this before without a problem but I keep getting errors this time
>>>
>>> I cant help wonder whether the code is OK (always was before) and I'm
>>> just not running it early enough
>>>
>>> Is there anyway I can run this code upon start up (not wait until the
>>> form opens on start up)

>>


 
Reply With Quote
 
Chris K
Guest
Posts: n/a
 
      18th Aug 2010
I posted the code below but here it is again:

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

RecordSource = "JHPmain"

etc
etc


"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
news:i4f9jk$qif$(E-Mail Removed)...
> Perhaps you should show the code you're using then.
>
> --
> Doug Steele, Microsoft Access MVP
> http://www.AccessMVP.com/djsteele
> Co-author: "Access 2010 Solutions", published by Wiley
> (no e-mails, please!)
>
>
>
> "Chris K" <(E-Mail Removed)> wrote in message
> news:t0jao.13129$2b4.9491@hurricane...
>> The error varies "JHPmain (form recordsource) does not exist" - sometimes
>> "Disk Error"
>>
>> Tried it in Form Open and still errors
>>
>> I found my old database with same routine in Form Load and it connects
>> all five table without issue
>>
>> I dont get it
>>
>> "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
>> news:i4c8fd$n70$(E-Mail Removed)...
>>> Knowing the errors would definitely help people...
>>>
>>> If the form is bound, then yes, the Load event it too late: try the Open
>>> event instead. Your best bet, though, might be to have an unbound form
>>> as your Startup form, and put the code in it (either Open or Load should
>>> work)
>>>
>>> --
>>> Doug Steele, Microsoft Access MVP
>>> http://www.AccessMVP.com/djsteele
>>> Co-author: "Access 2010 Solutions", published by Wiley
>>> (no e-mails, please!)
>>>
>>>
>>>
>>> "Chris K" <(E-Mail Removed)> wrote in message
>>> news:ESfao.110007$qO1.71499@hurricane...
>>>> I'm using code in a form open event to connect to back end table
>>>>
>>>>
>>>> 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 used this before without a problem but I keep getting errors this
>>>> time
>>>>
>>>> I cant help wonder whether the code is OK (always was before) and I'm
>>>> just not running it early enough
>>>>
>>>> Is there anyway I can run this code upon start up (not wait until the
>>>> form opens on start up)
>>>

>

 
Reply With Quote
 
Chris K
Guest
Posts: n/a
 
      18th Aug 2010
I copy/pasted the whole form/code and deleted the original and seems to be
working fine now - must got corrupted somehow

"Chris K" <(E-Mail Removed)> wrote in message
news:WSOao.41303$7E.16706@hurricane...
> I posted the code below but here it is again:
>
> 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
>
> RecordSource = "JHPmain"
>
> etc
> etc
>
>
> "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
> news:i4f9jk$qif$(E-Mail Removed)...
>> Perhaps you should show the code you're using then.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://www.AccessMVP.com/djsteele
>> Co-author: "Access 2010 Solutions", published by Wiley
>> (no e-mails, please!)
>>
>>
>>
>> "Chris K" <(E-Mail Removed)> wrote in message
>> news:t0jao.13129$2b4.9491@hurricane...
>>> The error varies "JHPmain (form recordsource) does not exist" -
>>> sometimes "Disk Error"
>>>
>>> Tried it in Form Open and still errors
>>>
>>> I found my old database with same routine in Form Load and it connects
>>> all five table without issue
>>>
>>> I dont get it
>>>
>>> "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
>>> news:i4c8fd$n70$(E-Mail Removed)...
>>>> Knowing the errors would definitely help people...
>>>>
>>>> If the form is bound, then yes, the Load event it too late: try the
>>>> Open event instead. Your best bet, though, might be to have an unbound
>>>> form as your Startup form, and put the code in it (either Open or Load
>>>> should work)
>>>>
>>>> --
>>>> Doug Steele, Microsoft Access MVP
>>>> http://www.AccessMVP.com/djsteele
>>>> Co-author: "Access 2010 Solutions", published by Wiley
>>>> (no e-mails, please!)
>>>>
>>>>
>>>>
>>>> "Chris K" <(E-Mail Removed)> wrote in message
>>>> news:ESfao.110007$qO1.71499@hurricane...
>>>>> I'm using code in a form open event to connect to back end table
>>>>>
>>>>>
>>>>> 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 used this before without a problem but I keep getting errors this
>>>>> time
>>>>>
>>>>> I cant help wonder whether the code is OK (always was before) and I'm
>>>>> just not running it early enough
>>>>>
>>>>> Is there anyway I can run this code upon start up (not wait until the
>>>>> form opens on start up)
>>>>

>>

 
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
My Dad Went To Prague, Now He's Back, he Can't Connect =?Utf-8?B?THVrZQ==?= Windows XP Setup 5 20th Jul 2007 10:43 PM
Using ADO to connect to back end database =?Utf-8?B?Sm9lQTIwMDY=?= Microsoft Access Database Table Design 1 28th Mar 2007 09:14 PM
cannot connect to back-end .mdb =?Utf-8?B?RGF2aWQj?= Microsoft Access 4 21st Mar 2007 02:12 AM
This code hangs on connect() if connect hangs. how to make this so that if connect hangs i time out after 10 seconds. perhaps there is someway to do this with ioctlsocket and select? can anyone show how to do this? Daniel Microsoft Windows 2000 Networking 0 15th Feb 2005 01:37 AM
Local Intranet code won't connect back to it's site of origin Lokaler News-Server Microsoft Dot NET 0 11th Sep 2003 12:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:56 AM.