Question

I want to create a split form based on a query where the fields are all grouped. The split form will not let me update the records because they are grouped. For instance let's say 10 records all had the same data in a field called "Company Name". Is there any way to make the query updatable such that when I change the data for "Company Name" on the grouped entry it will change for all of the records that are grouped?

Thanks

Was it helpful?

Solution

it is definitively not possible to update a grouped query. The reason is, that a grouped query cannot contain the key (if you include it, you have no more a grouping, as the key is unique ...)
So Access has no clue, what is grouped and which records should be updated

What you have to do is:

  • create a form based on the query
  • add an event "on double-click" to the field you want to change
  • program a dialog to ask for new value
  • fire an sql to update

here a sample for steps 2-4

Private Sub DOK_DokumentNr_DblClick(Cancel As Integer)

    Dim newvalue As Variant
    Dim sSQL As String

    newvalue = InputBox("enter new value", "DOC-Number", Me!DOK_DokumentNr.OldValue)
    If newvalue <> Me!DOK_DokumentNr.OldValue Then
        sSQL = "UPDATE T_Dokument SET DOK_DokumentNr = '" & newvalue & "' "
        sSQL = sSQL & "WHERE DOK_DokumentNr = '" & Me!DOK_DokumentNr.OldValue & "'"
        DoCmd.SetWarnings False ' to prevent the standard message for modifying data
        DoCmd.RunSQL sSQL
        DoCmd.SetWarnings True  ' reset warnings to default
    End If

End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top