Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

verifing linked tables

Status
Not open for further replies.

rjoshi2

Programmer
Sep 10, 2002
110
US
My question does this code look like it will work? The code that I am referring to comes after the CommandBar is created. The code has to due with verifying links. Is there a better way of to verify the links? Any help would be appreciated.

Thank you,
rjoshi

Here is my code:

Private Sub Form_Load()

'To Hide the Database Window
DoCmd.RunCommand acCmdWindowHide

Dim custombar As CommandBar
Dim newButton As CommandBarButton
Dim newButton2 As CommandBarButton

Set custombar = CommandBars.Add("Acquistion Log", msoBarBottom, False, True)

Set newButton = custombar.Controls _
.Add(msoControlButton)
With newButton
.Caption = "Main Switchboard"
.Parameter = "Main Switchboard"
.OnAction = "Toolbar: Main Switchboard"
If .Type = msoControlButton Then
.Style = msoButtonCaption
End If
End With

.
.
.
.

custombar.Visible = True
'CommandBars("Acquistion Log").Visible = True

Dim varReturn As Variant

' Verify Links using one table.
varReturn = CheckLink("PSC IT Acquisition Log")

If varReturn <> True Then
hardCoded
End If

End Sub

Private Function CheckLink(strTable As String) As Boolean
' In:
' strTable - table to check
' Out:
' Return Value - True if successful; False otherwise

Dim db As Database
Dim rst As Recordset

Set db = CurrentDb

On Error Resume Next
Set rst = db.OpenRecordset(strTable, dbOpenDynaset)

' Check for failure. If the OpenRecordSet failed, then
' the link must be bad.
If Err <> 0 Then
CheckLink = False
Else
rst.Close
CheckLink = True
End If

End Function

Function hardCoded()
Dim deleted As String
Dim todayDate As Date
Dim currentDay As Integer
'Get system's date
todayDate = Date
' Extracting Day from todayDate
currentDay = Day(todayDate)
DoCmd.SetWarnings False

'If currentDay = 9 Or currentDay = 18 Or currentDay = 27 Then
'hard coded table links
'If the directory is change where the data file is kept
'Then the path has to be change to reflect the new location

deleted = &quot;DROP TABLE [Core Data Dump]&quot;
DoCmd.RunSQL deleted
DoCmd.TransferDatabase acLink, &quot;Microsoft Access&quot;, &quot;\\Psc2\Data\Ocio\SHARED\Acquisitions\Back end of PSC IT Acquisition Log\PSC IT Acquisition Data File.mdb&quot; _
, acTable, &quot;Core Data Dump&quot;, &quot;Core Data Dump&quot;

deleted = &quot;DROP TABLE [PSC IT Acquisition Log]&quot;
DoCmd.RunSQL deleted
DoCmd.TransferDatabase acLink, &quot;Microsoft Access&quot;, &quot;\\Psc2\Data\Ocio\SHARED\Acquisitions\Back end of PSC IT Acquisition Log\PSC IT Acquisition Data File.mdb&quot; _
, acTable, &quot;PSC IT Acquisition Log&quot;, &quot;PSC IT Acquisition Log&quot;

deleted = &quot;DROP TABLE [tblObjClsDesc]&quot;
DoCmd.RunSQL deleted
DoCmd.TransferDatabase acLink, &quot;Microsoft Access&quot;, &quot;\\Psc2\Data\Ocio\SHARED\Acquisitions\Back end of PSC IT Acquisition Log\PSC IT Acquisition Data File.mdb&quot; _
, acTable, &quot;tblObjClsDesc&quot;, &quot;tblObjClsDesc&quot;

deleted = &quot;DROP TABLE [tblObjects]&quot;
DoCmd.RunSQL deleted
DoCmd.TransferDatabase acLink, &quot;Microsoft Access&quot;, &quot;\\Psc2\Data\Ocio\SHARED\Acquisitions\Back end of PSC IT Acquisition Log\PSC IT Acquisition Data File.mdb&quot; _
, acTable, &quot;tblObjects&quot;, &quot;tblObjects&quot;

deleted = &quot;DROP TABLE [tblObjectsInSystem]&quot;
DoCmd.RunSQL deleted
DoCmd.TransferDatabase acLink, &quot;Microsoft Access&quot;, &quot;\\Psc2\Data\Ocio\SHARED\Acquisitions\Back end of PSC IT Acquisition Log\PSC IT Acquisition Data File.mdb&quot; _
, acTable, &quot;tblObjectsInSystem&quot;, &quot;tblObjectsInSystem&quot;

DoCmd.SetWarnings True
'End If
End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top