Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    frankt68 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10

    How to build database correctly

    Hello!


    I need to create a database of employees and their authorizations for access to individual databases.
    Attached is a sample database.test2.accdb

    So I have a staff table (tEmployees) and a table with a list of databases (tDatabase). For each employee in the table, I need to add the database's ID to which he/she can access, like in example tAuthorized_access.
    I also need to export this to Word, so it will look like in this example
    test2.zip.

    I don't know much about Access so any help will be appreciated.

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    test2-davegri-v01.zip
    It's a Many-to-Many situation. Altered your tables to accommodate that. Set up form/subform to allow data entry assignments and added a report.
    Got rid of the multi-value field. If you're ever tempted to use them again, first come here again for advice.
    Last edited by davegri; 02-18-2019 at 05:17 PM. Reason: comment on multi-value fields

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    frankt68,
    Welcome to the forum. davegri has answered your specific question with a great example.
    For more info on database planning and design see links in my signature. There are also samples in the
    "Knowledge Base" area of this forum.
    Good luck with your project and learning Access.

  4. #4
    frankt68 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    Thanx davegri, your template is a very good solution to start with. It solves almost all I need, except for the export to Word.
    As I said, I need to export the data for each employee to Word and the databases ID's must be arranged and shown in a table form like in example test2.zip (this is a request of my boss).
    Any suggestion?

  5. #5
    frankt68 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    Quote Originally Posted by orange View Post
    frankt68,
    Welcome to the forum. davegri has answered your specific question with a great example.
    For more info on database planning and design see links in my signature. There are also samples in the
    "Knowledge Base" area of this forum.
    Good luck with your project and learning Access.
    Thanx. I'll certainly have a look.

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    I need to export the data for each employee to Word and the databases ID's must be arranged and shown in a table form like in example test2.zip (this is a request of my boss).
    Any suggestion?
    Nope, I don't have a quick answer for that.

  7. #7
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Access to word tables have a lot of formatting issues.

    The way I got around it was to have the data from access available in excel. Then you can copy and paste into an existing word table from excel.

    The code I have in excel is this:

    Code:
    Sub BetterExcelDataToWord()
    
    Dim objWord As Object, objDoc As Object
    Dim strFolder As String, strName As String
    Dim ws As Worksheet
    Dim lngLastRow As Long
    On Error GoTo Errorcatch
    
    
    ActiveWorkbook.RefreshAll
    Dim Ticker As Range
          
    strName = Sheet1.Range("i1").Value
    strFolder = "\\server\general\RAMS\RAM_RAMS\" & strName
    
    
    Sheets("PasteSpecial").Activate
    Sheets("PasteSpecial").Range("A4:H65").Delete
        
     Application.Wait (Now + TimeValue("00:00:05"))
        Sheets("RISKS").Activate
        Set Ticker = Range(Cells(4, 1), Cells(65, 8))
        Ticker.Copy
        
        Sheets("PasteSpecial").Activate
        Cells(4, 1).PasteSpecial xlPasteValues
    
    
    Debug.Print strFolder
    
    
    Set ws = ThisWorkbook.Sheets("PasteSpecial")
    lngLastRow = [LOOKUP(2,1/(A1:A65000<>""),ROW(A1:A65000))]
    Set objWord = CreateObject("Word.Application")
    ws.Range("A4" & ":H" & lngLastRow).Copy
    
    
    With objWord
      .Visible = True
      Set objDoc = .Documents.Open(strFolder)
    
    
      With objDoc.Bookmarks("RISKS").Range
        .Characters.Last.Next.PasteAppendTable
    
    
      End With
      .Activate
    End With
        
        Set ws = ThisWorkbook.Sheets("methodology")
       
        With objWord.ActiveDocument
         .Bookmarks("methodology").Range.Text = ws.Range("d1").Value
        End With
        Set objWord = Nothing: Set objDoc = Nothing
       
     Application.CutCopyMode = False
    
    
    Set ws = Nothing
       
       Exit Sub
    
    
    
    
    Errorcatch:
    Debug.Assert False
    MsgBox "Oops, an error has occured." & vbCrLf & vbCrLf & "Error Code : " & Err.Number & " , " & Err.Description
    
    
    End Sub
    If this is a path you wish to take I can help you out with some specifics.

    Andy

  8. #8
    frankt68 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    Quote Originally Posted by davegri View Post
    Nope, I don't have a quick answer for that.
    Thanx anyway.

  9. #9
    frankt68 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    Quote Originally Posted by davegri View Post
    Nope, I don't have a quick answer for that.
    Thanx anyway.

  10. #10
    frankt68 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    Quote Originally Posted by Homegrownandy View Post
    Access to word tables have a lot of formatting issues.

    The way I got around it was to have the data from access available in excel. Then you can copy and paste into an existing word table from excel.



    If this is a path you wish to take I can help you out with some specifics.

    Andy
    Thanx Andy, but I decided to first try to do it with aggregated mail merge in Word.

  11. #11
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    No problem. Just be aware its not possible to "merge table" as a special paste option from access to Word. If you need to do that then you must paste via excel. Otherwise good luck.
    Last edited by Homegrownandy; 02-22-2019 at 04:46 AM. Reason: Correction

  12. #12
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I have never tried to automate Word from Access (Excel - yes), but doing a search using keyword "ms word automation using Access", there were lots of returns.
    Maybe look at these to start with:

    https://www.microsoftaccessexpert.co...utomation.aspx
    http://www.brileigh.com/microsoft-ac...rosoft-access/
    https://stackoverflow.com/questions/...-word-document
    https://answers.microsoft.com/en-us/...6-ce31cb87730e
    https://www.techrepublic.com/blog/mi...h-access-data/

  13. #13
    frankt68 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    First of all - I apologize for the late reply, but I was busy with other matters.

    Secondly - thank you for pointing me in the right direction for searching the solution. I'm not quite there yet, but it's definitely a shift in the right direction.

  14. #14
    frankt68 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    First of all - I apologize for the late reply, but I was busy with other matters.

    Secondly - Steve, thank you for pointing me in the right direction for searching the solution. I'm not quite there yet, but it's definitely a shift in the right direction.

  15. #15
    Join Date
    Apr 2017
    Posts
    1,792
    Quote Originally Posted by frankt68 View Post
    As I said, I need to export the data for each employee to Word and the databases ID's must be arranged and shown in a table form like in example test2.zip (this is a request of my boss).
    I.e. a word document for single employee. It look like a task for Mail Merge. I am not sure, is it possible to use Access table or saved query as source for Mail Merge - I have used only Excel for this. But maybe someone here has some experience with this!

    And of course you can create an Excel workbook which queries data from access DB, and set the query to be refreshed on opening. And you create a Mail Merge in Word with this Excel workbook as source.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 18
    Last Post: 12-04-2017, 05:25 PM
  2. Replies: 4
    Last Post: 11-29-2015, 03:51 AM
  3. Build a database
    By chaddresnick in forum Access
    Replies: 2
    Last Post: 03-17-2015, 01:31 PM
  4. Using VBA or macros to build a database
    By Access_Novice in forum Access
    Replies: 11
    Last Post: 01-07-2015, 11:43 AM
  5. Build Database for Business
    By aggiemarine07 in forum Access
    Replies: 3
    Last Post: 11-07-2012, 03:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums