Randomblink
The Irreverent Reverend
- Local time
- Today, 10:16
- Joined
- Jul 23, 2001
- Messages
- 279
Ok.
Here is the problem.
I have created a database.
I have a front-end database that is filled with Forms, Reports, Modules, and Macros.
The only tables that the front-end database has are LINKED tables to what I call the back-end database.
The back-end database ONLY has tables.
I then go one step further.
I COPY the front-end database into an invisible folder.
I name it Template.mdb.
In my front-end (and of course the Template.mdb) database I have a Custom Property called "MasterVersion".
Whenever I need to add a form or a report to the database, I do the following:
Here is the problem.
I have created a database.
I have a front-end database that is filled with Forms, Reports, Modules, and Macros.
The only tables that the front-end database has are LINKED tables to what I call the back-end database.
The back-end database ONLY has tables.
I then go one step further.
I COPY the front-end database into an invisible folder.
I name it Template.mdb.
In my front-end (and of course the Template.mdb) database I have a Custom Property called "MasterVersion".
Whenever I need to add a form or a report to the database, I do the following:
- Open the Template.mdb file
- Make my changes, such as adding a report
- Goto File -> Database Properties -> Tab:Custom -> MasterVersion
- I change the MasterVersion to a different value
- Then I close the database which also saves it
- and I am finished
[/list=1]
Then, in the front-end / Template database there is a Macro.
It runs a function named: CompareVersion
This function, if you will check out the code below, checks the MasterVersion of the Template, compares it to the MasterVersion of the currently open front-end database, and if they are different, it grabs the Template version off the server, and overwrites the currently opened database with a copy of the Template.
This allows me, basically, to make changes to the Template database and everyone who has a copy of the front-end on their desktop will get updated with the newest version...
So far, this has worked without a problem... It has worked AT WORK on an NT4 server setup, with Windows 98 / MS Office 97... Then when work upgraded to Windows 2000 / Office 2000 it still worked... no problems... HOWEVER...
I recently created a database for a client... THEY are using Access 2002... They run Windows 2000 on their server with Windows 2000 on each desktop as well...
I made changes to the code to reflect different server locations... I set everything up to work on their system JUST LIKE IT DOES AT MY JOB PLACE... BUT, whenever I open the front-end from the desktop? Access tries to open hundreds of instances of itself... It tweaks and moans... It cries about Workgroups and Exclusive Access... NOTHING WORKS!
I am going crazy...
Almost EVERYTHING I have learned about Access Databases, I have learned from this forum.
I haven't had to ask a question in MONTHS...
I 'feel' like a moron...
SO...
I am posting my code here...
I am crossing my fingers...
Praying to every god I know...
And I am hoping that this is a simple 2000 vs. 2002 problem...
If someone can help me...?
I would be eternally grateful...
Here is my code...
Code:Option Compare Database Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Public Const ERROR_SUCCESS As Long = 0 Public Const CSIDL_DESKTOP As Long = &H0 Public Const CSIDL_PROGRAMS As Long = &H2 Public Const CSIDL_STARTMENU As Long = &HB Public Const CSIDL_DESKTOPDIRECTORY As Long = &H10 Public Const FO_COPY As Long = &H2 Public Const FOF_SILENT As Long = &H4 Public Const FOF_RENAMEONCOLLISION As Long = &H8 Public Const FOF_NOCONFIRMATION As Long = &H10 Public Type SHFILEOPSTRUCT hwnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAborted As Boolean hNameMaps As Long sProgress As String End Type Private Type BROWSEINFO hOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long Public Declare Function SHFileOperation Lib "Shell32" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As Long) As Long Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pv As Long) Private Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Const BIF_RETURNONLYFSDIRS = &H1 Dim appAccess As Access.Application, BlankHolder Public Function CompareVersion() On Error GoTo Err_CompareVersion Select Case GetMasterVersion Case GetCurrentVersion Case Else: CopySwap End Select Exit_CompareVersion: Exit Function Err_CompareVersion: errMessage Err Resume Exit_CompareVersion End Function Public Function GetMasterVersion() As String Dim wrkJet As Workspace Dim dbs As DAO.Database, cnt As Container Dim doc As Document, prp As Property ' Property not found error. Const conPropertyNotFound = 3270 On Error GoTo GetSummary_Err Set wrkJet = CreateWorkspace("", "User", "") Set dbs = wrkJet.OpenDatabase("\\PW\engineering\wpdata\reports\Databases\Front_End_Databases\Template.mdb") Set doc = dbs.Containers("Databases")!UserDefined GetMasterVersion = doc.Properties("MasterVersion") dbs.Close wrkJet.Close Set doc = Nothing Set dbs = Nothing GetSummary_Bye: Exit Function GetSummary_Err: If Err = conPropertyNotFound Then MsgBox "There is no Master Version number assigned." Resume Else ' Unknown error. MsgBox Err.Description Resume GetSummary_Bye End If End Function Public Function GetCurrentVersion() As String Dim dbs As DAO.Database, cnt As Container, GetTemplateLocation As String Dim doc1 As Document, doc2 As Document, prp As Property ' Property not found error. Const conPropertyNotFound = 3270 On Error GoTo GetSummary_Err Set dbs = CurrentDb Set cnt = dbs.Containers!Databases Set doc1 = cnt.Documents!UserDefined doc1.Properties.Refresh GetCurrentVersion = doc1.Properties("MasterVersion") GetSummary_Bye: Exit Function GetSummary_Err: If Err = conPropertyNotFound Then MsgBox "There is no Replica Version number assigned." Resume Else ' Unknown error. Resume GetSummary_Bye End If End Function Public Function CopySwap() Dim fs On Error GoTo Err_CopySwap ' Create a target that points to where the new version should go. ' TrgtLoc = "C:\WINNT\Profiles\" & GetNTUser & "\Desktop\ProjectStatus.mdb" ' Start up the COPY FUNCTION. Set fs = CreateObject("Scripting.FileSystemObject") ' Get the original Template and copy it to where new versions go. (True means to overwrite if a copy exists.) fs.CopyFile "\\PW\engineering\wpdata\reports\Databases\Front_End_Databases\Template.mdb", TNmLoc, True ' Start up the OPEN DATABASE FUNCTION. Set appAccess = CreateObject("Access.Application") ' Open the new database that was just copied from the Template. appAccess.OpenCurrentDatabase TNmLoc, False ' Close the old version of the database. DoCmd.Quit acQuitSaveNone Exit_CopySwap: Call CompareVersion Exit Function Err_CopySwap: MsgBox Err.Description Resume Exit_CopySwap End Function Public Sub CreateDesktopLink(sSource As String, sDestination As String) 'working variables Dim sFiles As String, SHFileOp As SHFILEOPSTRUCT 'terminate passed strings with a null sSource = sSource & Chr$(0) sDestination = sDestination & Chr$(0) 'set up the options With SHFileOp .wFunc = FO_COPY .pFrom = sSource .pTo = sDestination .fFlags = FOF_SILENT Or FOF_NOCONFIRMATION End With 'and perform the copy Call SHFileOperation(SHFileOp) End Sub Public Function GetSpecialFolder(hwnd As Long, CSIDL As Long) As String Dim pidl As Long, pos As Long, sPath As String 'fill the pidl with the specified folder item If SHGetSpecialFolderLocation(hwnd, CSIDL, pidl) = ERROR_SUCCESS Then 'initialize & get the path sPath = Space$(260) If SHGetPathFromIDList(ByVal pidl, ByVal sPath) Then 'has a null? pos = InStr(sPath, Chr$(0)) 'strip it If pos Then 'return folder GetSpecialFolder = Left$(sPath, pos - 1) End If End If End If Call CoTaskMemFree(pidl) End Function Public Function TNmLoc() As String On Error GoTo Err_TNmLoc Dim DskTp As String, DbNm As String DskTp = GetSpecialFolder(0&, CSIDL_DESKTOPDIRECTORY) DbNm = "\Midwest Customer Application.mdb" TNmLoc = DskTp & DbNm Exit_TNmLoc: Exit Function Err_TNmLoc: MsgBox Err.Description Resume Exit_TNmLoc End Function Public Function GetNTUser() As String On Error GoTo Err_GetNTUser 'Returns the network login name Dim strUserName As String 'Create a buffer strUserName = String(100, Chr$(0)) 'Get user name GetUserName strUserName, 100 'Strip the rest of the buffer strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1) GetNTUser = LCase(strUserName) Exit_GetNtUser: Exit Function Err_GetNTUser: MsgBox Err.Description Resume Exit_GetNtUser ' SAMPLE USAGE: ' Me!<insert field name here> = GetNTUser End Function
Thank you if you can help... or even offer a suggestion for an alternative way to go... I am open to anything...
Thank you all...