Relink table after offline (1 Viewer)

tt1611

Registered User.
Local time
Today, 16:46
Joined
Jul 17, 2009
Messages
132
Good day all
I have a access 2003 front end linked to sql server tables. My app is a field system that allows for users to go offline and work of local tables or come back online and work off the linked tables.

I have a form that runs the necessary code to check the status of the current connection and go into online/offline mode as necessary.

During testing I can get my code to do what it is supposed to do when offline and vice versa. What I am having problems with is refreshing/relinking the tables when the user comes back online. If a refresh was attempted when the user was offline, what happens is when they plug back into the network and reattempt the connection, it is still acting as though the laptop is offline.

Please see my code that fires up when the main menu is open.

Code:
Private Sub cmdconnect_Click()
On Error GoTo err_ConnectFail
Dim Dbs As Database
Dim Tdf As TableDef
 
Set Dbs = CurrentDb
For Each Tdf In Dbs.TableDefs
If Len(Tdf.Connect) > 0 Then
Tdf.RefreshLink
End If
Next
 
DoCmd.SetWarnings False
Me.progbr.Visible = True
'Updates Single Inventories to devices table
DoCmd.OpenQuery "FacDel"
Me.progbr.Value = 10
'inserts newly inventoried devices into devices table
DoCmd.OpenQuery "UpdateFac"
Me.progbr.Value = 20
'inserts newly inventoried net devices into network devices table
DoCmd.OpenQuery "InsertDevices"
Me.progbr = 30
'deletes all current PC records
DoCmd.OpenQuery "InsertNetDevices"
Me.progbr = 40
'deletes all recorded sub devices records
DoCmd.OpenQuery "DevicesHoldDel"
Me.progbr = 50
'deletes all facilities from the local table
DoCmd.OpenQuery "NetDevicesDel"
Me.progbr = 50
'Deletes all records from the net devices holder inventories updated earlier
DoCmd.OpenQuery "UpdateSingleInv"
Me.progbr = 60
'Deletes all records from the devices holder inventories updated earlier
DoCmd.OpenQuery "DevicesCheckDel"
Me.progbr = 70
'Updates the PC Check table with current PC Information
DoCmd.OpenQuery "DelPCCheck"
Me.progbr = 80
'Updates the local facilities table with current facility Information
DoCmd.OpenQuery "UpdateDevices"
Me.progbr = 90
'Updates the devices check table with current devices and serial Information
DoCmd.OpenQuery "UpdatePCs"
Me.progbr = 100
 
Me.progbr.Visible = False
MsgBox "Mobile Inventory successfully updated", vbOKOnly + vbInformation, "FIS"
DoCmd.SetWarnings True
Me.Caption = "FIS Main Menu. Status - Online Mode"
Me.cmdin.Enabled = True
Me.cmdout.Enabled = True
Me.cmdstatus.Enabled = True
 
err_ConnectFail:
Dim errN As DAO.Error
If Errors.Count > 1 Then
For Each errN In DAO.Errors
If errN.Number = 11004 Or errN.Number = 3146 Or errN.Number = 3151 Then
MsgBox "Connection to database failed. Offline Mode activated" & vbNewLine & "Check Ethernet cable and reattempt connect", vbOKOnly + vbCritical, "FIS"
Me.cmdin.Enabled = False
Me.cmdout.Enabled = False
Me.cmdstatus.Enabled = False
Me.Caption = "FIS Main Menu. Status - Offline Mode"
End If
Next errN
Else
End If
End Sub

In order for the refresh to kick in, the app has to be restarted before access will realise that it is back online.
Is there any line of code I am missing that lets access know to go back online even if a failed refresh had been attempted

My tdf.refreshlink is still showing false status.

Please let me know if you need any other information.

Thanks and regards.
 
Last edited:

tt1611

Registered User.
Local time
Today, 16:46
Joined
Jul 17, 2009
Messages
132
FYI (Edit) - I have noticed on further testing that leaving the system plugged in for about 10 minutes will allow the tables to be refreshed fine. Is it normal for this to happen and not fire the refreshlink immediately?
 

Users who are viewing this thread

Top Bottom