Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Re: update all filtered records in a sum form

Discussion in 'Information Technology' started by Simon, Jul 28, 2006.

  1. Simon

    Simon
    Expand Collapse
    Guest

    Hi Arvin,
    Thanks for your response.
    Can you tell me what I need to use where you have entered "Whatever" in your
    code. I assumed it would be the name of the sub form followed by the field
    but I don't know how to refer to that with the options provided.
    Also I assume where you have written "Me.txtWhatever" this is the name of
    the control on the main form ?
    Thank you

    "Arvin Meyer [MVP]" wrote:

    > Looks like I forgot to loop:
    >
    > Sub txtWhatever_AfterUpdate()
    >
    > Dim db As DAO.Database
    > Dim rst As DAO.Recordset
    > Set db = CurrentDb
    > Set rst = Me.RecordsetClone
    > Do Until rst.EOF
    > With rst
    > .MoveFirst
    > .Edit
    > .Whatever = Me.txtWhatever
    > .Update
    > .MoveNext
    > End With
    > Loop
    > rst.Close
    > Set rst = Nothing
    > Set db = Nothing
    > Me.Refresh
    >
    > End Sub
    > --
    > Arvin Meyer, MCP, MVP
    > Microsoft Access
    > Free Access downloads
    > http://www.datastrat.com
    > http://www.mvps.org/access
    >
    > "Arvin Meyer [MVP]" <a@m.com> wrote in message
    > news:Ol7qbGccGHA.4900@TK2MSFTNGP02.phx.gbl...
    > > "Simon" <Simon@discussions.microsoft.com> wrote in message
    > > news:E61E49AA-DC0D-4D26-921B-6AF993A93294@microsoft.com...
    > > > I am using Access 2003 and have a form based on 1 table, with a subform

    > > based
    > > > on another. Typically the sub form which is continuous contains 1-6

    > > records.
    > > > I want to be able to update a date field on the main form which then

    > > updates
    > > > a date field in all filtered records of the sub form. I have tried doing

    > > this
    > > > using the after update event on the field in the main form but this only
    > > > updates the sub form record which has the focus. Any suggestions would

    > be
    > > > most appreciated.

    > >
    > > I have no way to test this but it should work for you:
    > >
    > > In the AfterUpdate event of the textbox that you want to change, build a
    > > recordset based on the form's recordsetclone. (air code):
    > >
    > > Sub txtWhatever_AfterUpdate()
    > >
    > > Dim db As DAO.Database
    > > Dim rst As DAO.Recordset
    > > Set db = CurrentDb
    > > Set rst = Me.RecordsetClone
    > > With rst
    > > .MoveFirst
    > > .Edit
    > > .Whatever = Me.txtWhatever
    > > .Update
    > > .MoveNext
    > > End With
    > > rst.Close
    > > Set rst = Nothing
    > > Set db = Nothing
    > > Me.Refresh
    > >
    > > End Sub
    > > --
    > > Arvin Meyer, MCP, MVP
    > > Microsoft Access
    > > Free Access downloads
    > > http://www.datastrat.com
    > > http://www.mvps.org/access
    > >
    > >

    >
    >
    >
     
  2. Loading...


Share This Page