Front-End Back-end relationship...

Matt_Hirst

Access Numpty
Local time
Today, 20:34
Joined
Nov 25, 2006
Messages
15
I have an app where I have split the data from the code , if the app is moved to a differnt location the link between the front-end and the back-end is unchanged. Question is how do I change this through code?

regards,

Matt

P.S. I know I can do it manually, but just wondered how to update it automaticly.
 
I have written this code for this purpose, I hope you can use it (and keep me as a reference ;) )
Code:
' Creator: namliaM
' Created: 2005-11-05
' Forum: www.access-programmers.co.uk/forums
' This runs in a form, with a progress meter on it
' and relinks this front end to the backend which is located
' in a subfolder called Tables, this form by default opens invisible.
    Dim tbl As dao.TableDef
    Dim x As Long, MaxX As Long
    Dim tblDB As String
    
    Me.Visible = False
    
    tblDB = myCurrDir & "Tables\*.mdb"
    If Dir(tblDB) = "" Then
        MsgBox "No table database has been found, " & vbCr & vbCr & _
               "This application will not work, so its beeing closed", vbCritical
        Application.Quit
    End If
    
    resetShadows
                        
    MaxX = 1 ' first count all attached tables
    For Each tbl In CurrentDb.TableDefs()
        If tbl.Attributes = dbAttachedTable Then MaxX = MaxX + 1
    Next tbl
    x = 1 ' Now update them
    For Each tbl In CurrentDb.TableDefs()
        If tbl.Attributes = dbAttachedTable Then
            tblDB = myCurrDir & Mid(tbl.Connect, InStr(1, tbl.Connect, "Tables"))
            If tbl.Connect <> ";Database=" & tblDB Then
                Me.Visible = True
                Me.Repaint
                DoEvents
                tbl.Connect = ";Database=" & tblDB
                tbl.RefreshLink
                
            End If
            x = x + 1
        End If
        Me.Fill.Width = x / MaxX * Me.FillTo.Width
    Next tbl
    If Me.Visible Then
        Me.lblWait.Caption = "Done relinking ... "
        Me.Repaint
        MaxX = Timer + 2
        Do While Timer <= MaxX
        Loop
    End If

    DoCmd.OpenForm "frmMain"
    DoCmd.Close acForm, Me.Name
Code:
Public Function myCurrDir() As String
' a little function to get the current directory of the DB.
    myCurrDir = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\", -1, vbTextCompare))
End Function
 
How to prevent other users from edit our data in a multiusers environment

Hi!

I have a problem in my access database which is located in a server for multiuser environment. The system is allow user to add record and then print out the report. My problem is, if there are two person login to the database simultanueously, they can view other user's data in the same report. But I want to set the report to show thier own data only. Therefore is there any solutions fot it.

Thank you.
 
Strange, I think you meant to open a new thread for that... but here goes.
Environ("Username") returns the person logged on in windows.
You can store this data in the table(s) and use that as a restriction in your reports and forms. Thus the user can only see their own data.

Alternatively you need to set up some sort of security if a user should be able to see the data for some other user(s) as well.
 
Hi all,
if the user change the place of the FrontEnd DB, at that situation what to do? and How relink the frontEnd and BackEnd? and if the BackEnd is on the Server?
 

Users who are viewing this thread

Back
Top Bottom