I have a pice of code in access which refreshes the tables but how do i get a browse button in the code i have to give the option to find it.
Cheers Jason
Public Function RefreshAttachments()
Dim sTemporaryDatabase As String, sMainDatabase As String, sArchiveDatabase As String
Dim iTableCount As Integer, iAttachCount As Integer
sMainDatabase = GetSetting(ProgramName, "Files", "MainDatabase", "")
sMainDatabase = InputBox$("Enter the location of the system's main database", , sMainDatabase)
If sMainDatabase > "" Then
SaveSetting ProgramName, "Files", "MainDatabase", sMainDatabase
iTableCount = 28
iAttachCount = Abs(AttachTable(sMainDatabase, "Changeover Time"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Circulation Group"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Circulation List"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Concept Notification"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Customer"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Commercial and Development"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Factory Trial Record"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Gate"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Micro Shelflife"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Organoleptic Shelflife"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Planning Issues"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Process Technologist Issues"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Purchasing Issues"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Technical Issues"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development Header"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development Recipe"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Group Report"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Pack Type"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Person Customer"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Person Group"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Person Site"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Personnel"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Preservation Method"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Processing Step"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Product Master"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Reports"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Site"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Supplier"))
If iTableCount = iAttachCount Then
MsgBox "Main database tables now attached to " & sMainDatabase, vbInformation
Else
MsgBox "The was an error attaching the main database tables to " & sMainDatabase, vbInformation
End If
End If
sTemporaryDatabase = GetSetting(ProgramName, "Files", "TemporaryDatabase", "")
sTemporaryDatabase = InputBox$("Enter the location of the system's temporary database", , sTemporaryDatabase)
If sTemporaryDatabase > "" Then
SaveSetting ProgramName, "Files", "TemporaryDatabase", sTemporaryDatabase
iTableCount = 1
iAttachCount = Abs(AttachTable(sTemporaryDatabase, "Temp: Print List"))
If iTableCount = iAttachCount Then
MsgBox "Temporary database tables now attached to " & sTemporaryDatabase, vbInformation
Else
MsgBox "The was an error attaching the temporary database tables to " & sTemporaryDatabase, vbInformation
End If
End If
sArchiveDatabase = GetSetting(ProgramName, "Files", "ArchiveDatabase", "")
sArchiveDatabase = InputBox$("Enter the location of the system's archive database", , sArchiveDatabase)
If sArchiveDatabase > "" Then
SaveSetting ProgramName, "Files", "ArchiveDatabase", sArchiveDatabase
iTableCount = 12
iAttachCount = Abs(AttachTable(sArchiveDatabase, "Concept Notification", "Concept Notification (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Commercial and Development", "Development - Commercial and Development (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Factory Trial Record", "Development - Factory Trial Record (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Gate", "Development - Gate (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Micro Shelflife", "Development - Micro Shelflife (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Organoleptic Shelflife", "Development - Organoleptic Shelflife (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Planning Issues", "Development - Planning Issues (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Process Technologist Issues", "Development - Process Technologist Issues (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Purchasing Issues", "Development - Purchasing Issues (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Technical Issues", "Development - Technical Issues (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development Header", "Development Header (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development Recipe", "Development Recipe (archive)"))
If iTableCount = iAttachCount Then
MsgBox "Archive database tables now attached to " & sArchiveDatabase, vbInformation
Else
MsgBox "The was an error attaching the archive database tables to " & sArchiveDatabase, vbInformation
End If
End If
End Function
Cheers Jason
Public Function RefreshAttachments()
Dim sTemporaryDatabase As String, sMainDatabase As String, sArchiveDatabase As String
Dim iTableCount As Integer, iAttachCount As Integer
sMainDatabase = GetSetting(ProgramName, "Files", "MainDatabase", "")
sMainDatabase = InputBox$("Enter the location of the system's main database", , sMainDatabase)
If sMainDatabase > "" Then
SaveSetting ProgramName, "Files", "MainDatabase", sMainDatabase
iTableCount = 28
iAttachCount = Abs(AttachTable(sMainDatabase, "Changeover Time"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Circulation Group"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Circulation List"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Concept Notification"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Customer"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Commercial and Development"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Factory Trial Record"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Gate"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Micro Shelflife"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Organoleptic Shelflife"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Planning Issues"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Process Technologist Issues"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Purchasing Issues"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Technical Issues"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development Header"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development Recipe"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Group Report"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Pack Type"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Person Customer"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Person Group"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Person Site"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Personnel"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Preservation Method"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Processing Step"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Product Master"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Reports"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Site"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Supplier"))
If iTableCount = iAttachCount Then
MsgBox "Main database tables now attached to " & sMainDatabase, vbInformation
Else
MsgBox "The was an error attaching the main database tables to " & sMainDatabase, vbInformation
End If
End If
sTemporaryDatabase = GetSetting(ProgramName, "Files", "TemporaryDatabase", "")
sTemporaryDatabase = InputBox$("Enter the location of the system's temporary database", , sTemporaryDatabase)
If sTemporaryDatabase > "" Then
SaveSetting ProgramName, "Files", "TemporaryDatabase", sTemporaryDatabase
iTableCount = 1
iAttachCount = Abs(AttachTable(sTemporaryDatabase, "Temp: Print List"))
If iTableCount = iAttachCount Then
MsgBox "Temporary database tables now attached to " & sTemporaryDatabase, vbInformation
Else
MsgBox "The was an error attaching the temporary database tables to " & sTemporaryDatabase, vbInformation
End If
End If
sArchiveDatabase = GetSetting(ProgramName, "Files", "ArchiveDatabase", "")
sArchiveDatabase = InputBox$("Enter the location of the system's archive database", , sArchiveDatabase)
If sArchiveDatabase > "" Then
SaveSetting ProgramName, "Files", "ArchiveDatabase", sArchiveDatabase
iTableCount = 12
iAttachCount = Abs(AttachTable(sArchiveDatabase, "Concept Notification", "Concept Notification (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Commercial and Development", "Development - Commercial and Development (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Factory Trial Record", "Development - Factory Trial Record (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sMainDatabase, "Development - Gate", "Development - Gate (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Micro Shelflife", "Development - Micro Shelflife (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Organoleptic Shelflife", "Development - Organoleptic Shelflife (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Planning Issues", "Development - Planning Issues (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Process Technologist Issues", "Development - Process Technologist Issues (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Purchasing Issues", "Development - Purchasing Issues (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development - Technical Issues", "Development - Technical Issues (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development Header", "Development Header (archive)"))
iAttachCount = iAttachCount + Abs(AttachTable(sArchiveDatabase, "Development Recipe", "Development Recipe (archive)"))
If iTableCount = iAttachCount Then
MsgBox "Archive database tables now attached to " & sArchiveDatabase, vbInformation
Else
MsgBox "The was an error attaching the archive database tables to " & sArchiveDatabase, vbInformation
End If
End If
End Function