Hidden Start-Up form to re-connect FE to BE

S

Sierras

I?m having a little trouble with re-connecting the front end of a database
with the back end using code in a hidden start-up form.
I got this code from one the users of this forum (Thanks Mike) and then
modified it to suit my database. But I can?t get it work properly and
hope someone can find my mistake.

If the BE is in the same folder as the FE, then the reconnect function
from PETER VUKOVIC is called (http://allenbrowne.com/ser-13.html). This
function seems to work, but only on the second opening of the database.
That is, on the first opening after the BE is moved to a different folder,
the function works, but the start-up form pops up anyway. If I just close
the program and start again, the tables are all linked.

Here is my start-up form which is supposed to be hidden if the BE and FE
are already linked or in the same folder. Is there anything obviously
wrong with this?

Private Sub Form_Open(Cancel As Integer)
' try to open a recordset with this table
If Not InitOk("tblEmployees") Then
' did not work, so maybe data file is in this folder
If Not (Reconnect = True) Then
' did not work, so continue opening this form
End If
Else
' links OK now, so open switchboard
DoCmd.OpenForm "frmSwitchBoard"
' and cancel opening this form
Cancel = True
End If
' links are already OK, so open switchboard
End Sub
 
S

Sierras

Just a small correction. I should have written,

That is, on the first opening after the BE and FE is moved to a
different folder (but still in the same folder), the function works,
but the start-up form pops up anyway. If I just close the program
and start again, the tables are all linked.

This is to simulate a user getting a new FE design and putting it in
the same folder as the BE.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top