Results 1 to 10 of 10
  1. #1
    seocavaz is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    26

    Fill out all records of a look up table with one form

    I have this look up table:



    ID POF COF Iinterval RiskMatrix
    1 1 6 10 1
    2 1 5 7 2
    3 1 4 5 3
    4 1 3 3 4
    5 1 2 1 5
    6 1 1 1 6
    7 2 6 12 7
    8 2 5 10 8
    9 2 4 7 9
    10 2 3 5 10
    11 2 2 3 11
    12 2 1 1 12
    13 3 6 15 13
    14 3 5 12 14
    15 3 4 10 15
    16 3 3 7 16
    17 3 2 5 17
    18 3 1 3 18
    19 4 6 20 19
    20 4 5 15 20
    21 4 4 12 21
    22 4 3 10 22
    23 4 2 7 23
    24 4 1 5 24
    25 5 6 20 25
    26 5 5 20 26
    27 5 4 15 27
    28 5 3 12 28
    29 5 2 10 29
    30 5 1 7 30
    31 6 6 20 31
    32 6 5 20 32
    33 6 4 20 33
    34 6 3 15 34
    35 6 2 12 35
    36 6 1 10 36

    and I would like to use the form attached to fill out the [iinterval] column. [RiskMatrix] in the table corresponds with the square on the matrix-form attached.

    any help would be much appreciated!
    Attached Thumbnails Attached Thumbnails Capture.JPG  

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Not a clue what you want to do. Everything appears to be filled in.
    Would you try and explain again??? What results do you want??

  3. #3
    seocavaz is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    26
    sorry, hopefully this is clearer.

    I want to be able to type values in the colored squares in the matrix and have it update the corresponding record in the table. ie. where the cursor is is [riskmatrix]=1 so I want to be able to type 15 in that yellow square and it change the [iinterval] from 10 to 15.

  4. #4
    seocavaz is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    26
    In my google search I found this:

    Private Sub Risk1CT_AfterUpdate()

    update frm_matrix - inspectionintervals
    Set [tbl_inspectioninterva].[Iinterval] = [frm_matrix-inspectionintervals].[Risk1CT]
    WHERE tbl_inspectioninterval.[RiskMatrix] = 1

    End Sub

    however I keep getting sub or function not defined.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    CurrentDb.Execute "UPDATE [tbl_inspectioninterval] SET [Iinterval] = " & Me.Risk1CT & " WHERE [RiskMatrix] = 1"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So you will have to write 36 SQL update statements.

    OR you might think about writing a UDF with arguments. Something like
    (AIR CODE)
    Code:
    Sub UpdateInterval(intInterval As Integer, intRiskMatrix As Integer)
    
        CurrentDb.Execute "UPDATE [tbl_inspectioninterval] SET [Iinterval] = " & intInterval & " WHERE [RiskMatrix] = " & intRiskMatrix
    
    End Sub

    To update interval, you would use:
    Code:
    Private Sub Risk1CT_AfterUpdate()
       Call UpdateInterval(Risk1CT, 1)
    End Sub
    For another "colored box" (you have a control there, right?), you would use:
    Code:
    Private Sub Risk2CT_AfterUpdate()
       Call UpdateInterval(Risk2CT, 2)
    End Sub
    Would do this 36 times.


    Be warned, "Interval" is a reserved word in Access - shouldn't be used for object names.

  7. #7
    seocavaz is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    26
    Perfect! thanks for everyone's help!

  8. #8
    seocavaz is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    26
    Is there any way to also have it show the latest in the form when you open it? ie. shows all of the original records in from the table, and as I update them, they stay for the next time we open to review/change?

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That would require code to pull the values from table and populate the unbound controls in some event, possibly form Open or Load. Something like:

    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset ("SELECT * FROM tablename;")
    rs.MoveFirst
    While Not rs.EOF
    Me("Risk" & rs!RiskMatrix & "CT") = rs!linterval
    rs.MoveNext
    Wend
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    seocavaz is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    26
    thanks! I had to figure out how to turn on the DAO library, but now it works perfect

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 29
    Last Post: 05-06-2015, 10:18 AM
  2. Replies: 1
    Last Post: 10-28-2013, 01:54 PM
  3. Replies: 6
    Last Post: 09-10-2012, 07:19 AM
  4. Replies: 16
    Last Post: 11-02-2011, 01:35 PM
  5. Replies: 5
    Last Post: 09-14-2011, 03:41 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