Results 1 to 5 of 5
  1. #1
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Unhappy Cant update the Query I have created

    I have a table containing Student_info including a Target field and Draft_tier.

    I have another table Pap_info which contains fields Target and Tier.

    I need to lookup the [Student_info].[target field] value in the Pap_info table and return the Tier value to be stored in the Draft_tier column (as a sort of default).

    My initial efforts resulted in the following code which creates the datasheet I need but the data cant be edited.


    Code:
    strSQL = SQLSTR(Me.Combo_class.Value, Me.Yeargp.Value)
    fieldtest = "[Mathematics_Group]"
    group = Me.Combo_class.Value
    Yr = Me.Yeargp.Value
    For Each qdf In CurrentDb.QueryDefs
     If qdf.Name = "newquery" Then
         CurrentDb.QueryDefs.Delete "newquery"
          Exit For
       End If
    Next
    strSQL = "SELECT LOWER_SCHOOL_Students.[First name], LOWER_SCHOOL_Students.[Last name], LOWER_SCHOOL_Students.Mathematics_Group,   Nov_tier.exam_tier_dft " _
                & " FROM LOWER_SCHOOL_Students LEFT JOIN Nov_tier ON LOWER_SCHOOL_Students.[Mathematics_Target] = Nov_tier.grade" _
                & " WHERE (((LOWER_SCHOOL_Students.[Mathematics_Group])=" & Chr(34) & group & Chr(34) & "));"
    Set qdf = CurrentDb.CreateQueryDef("Newquery", strSQL)
    DoCmd.OpenQuery "NewQuery", 0, acEdit
    all help gladly appreciated.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Access is very picky about Update queries, only the most basic queries allow updating. You could put the LEFT JOIN into a subquery or else you need to make a temp table.

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    not tried, but so long as you are only editing data in the LOWER_SCHOOL_Students table, try changing the form recordset type to dynaset inconsistent updates - might work

    you won't be able to edit nulls on the Nov_tier table because the record doesn't exist to edit

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Thanks for this advice. Clearly whilst I'm grasping some general code stuff, im still learning what does and doesn't work. I love the idea of temporary tables so that's my next step.

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    When you want to be able to edit a multi-table query, at least one of the fields (preferably both) used in the join expression must be indexed.

    Try putting indexes (they don't have to be unique) on Students.[Mathematics_Target] and nov_tier.grade.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-22-2016, 03:38 PM
  2. Replies: 3
    Last Post: 05-21-2015, 11:26 AM
  3. Replies: 8
    Last Post: 07-24-2014, 09:29 PM
  4. Replies: 1
    Last Post: 06-03-2014, 06:56 AM
  5. New Field Name on Newly created query
    By inan25 in forum Queries
    Replies: 3
    Last Post: 05-13-2009, 09:05 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