Welcome to SPN

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

Sign Up Now!

Manipulating data

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

  1. Chuck Neal

    Chuck Neal
    Expand Collapse
    Guest

    Is there a way to do this?

    If Field One = X AND Field Two = Y, then replace Field One with Z.

    I assume it's some sort of update query.

    Any help would be appreciated.
     
  2. Loading...


  3. SusanV

    SusanV
    Expand Collapse
    Guest

    UPDATE YourTable SET YourTable.FieldOne = "Z"
    WHERE (((YourTable.FieldOne )="X") AND ((YourTable.FieldTwo)="Y"));

    --
    hth,
    SusanV



    "Chuck Neal" <ChuckNeal@discussions.microsoft.com> wrote in message
    news:F0F1BAE1-A199-4273-B9EE-47D69D41CB3A@microsoft.com...
    > Is there a way to do this?
    >
    > If Field One = X AND Field Two = Y, then replace Field One with Z.
    >
    > I assume it's some sort of update query.
    >
    > Any help would be appreciated.
     
  4. Chuck Neal

    Chuck Neal
    Expand Collapse
    Guest

    I'm a novice. Does this go in a query or is it VBA?

    "SusanV" wrote:

    > UPDATE YourTable SET YourTable.FieldOne = "Z"
    > WHERE (((YourTable.FieldOne )="X") AND ((YourTable.FieldTwo)="Y"));
    >
    > --
    > hth,
    > SusanV
    >
    >
    >
    > "Chuck Neal" <ChuckNeal@discussions.microsoft.com> wrote in message
    > news:F0F1BAE1-A199-4273-B9EE-47D69D41CB3A@microsoft.com...
    > > Is there a way to do this?
    > >
    > > If Field One = X AND Field Two = Y, then replace Field One with Z.
    > >
    > > I assume it's some sort of update query.
    > >
    > > Any help would be appreciated.

    >
    >
    >
     
  5. John Vinson

    John Vinson
    Expand Collapse
    Guest

    On Tue, 13 Jun 2006 09:48:02 -0700, Chuck Neal
    <ChuckNeal@discussions.microsoft.com> wrote:

    >Is there a way to do this?
    >
    >If Field One = X AND Field Two = Y, then replace Field One with Z.
    >
    >I assume it's some sort of update query.
    >
    >Any help would be appreciated.


    Create a new Query based on your Table.
    Select Field One and Field Two. Put "X" on the Criteria line under
    Field One, and "Y" on the Criteria line under Field Two. Open the
    query in datasheet view to verify that you're selecting the desired
    records, and only those.
    Change the query to an Update query using the query type icon, or the
    Query menu option.
    Type "Z" on the Update To line under Field One.
    Run the query by clicking the ! icon.

    John W. Vinson[MVP]
     
  6. SusanV

    SusanV
    Expand Collapse
    Guest

    This is a query, replace the fields with your fields, or simply use the
    query builder (design view) set it to be an Update Query, and set your
    criteria. John's reply explains this well.

    If you want to run this in VBA, it would be DoCmd.RunSQL "UPDATE YourTable
    SET YourTable.FieldOne = 'Z' WHERE (((YourTable.FieldOne )='X') AND
    ((YourTable.FieldTwo)='Y'));"


    --
    hth,
    SusanV



    "Chuck Neal" <ChuckNeal@discussions.microsoft.com> wrote in message
    news:A7493F3A-3448-4481-914A-A045BFA5EC3F@microsoft.com...
    > I'm a novice. Does this go in a query or is it VBA?
    >
    > "SusanV" wrote:
    >
    >> UPDATE YourTable SET YourTable.FieldOne = "Z"
    >> WHERE (((YourTable.FieldOne )="X") AND ((YourTable.FieldTwo)="Y"));
    >>
    >> --
    >> hth,
    >> SusanV
    >>
    >>
    >>
    >> "Chuck Neal" <ChuckNeal@discussions.microsoft.com> wrote in message
    >> news:F0F1BAE1-A199-4273-B9EE-47D69D41CB3A@microsoft.com...
    >> > Is there a way to do this?
    >> >
    >> > If Field One = X AND Field Two = Y, then replace Field One with Z.
    >> >
    >> > I assume it's some sort of update query.
    >> >
    >> > Any help would be appreciated.

    >>
    >>
    >>
     
  7. Chuck Neal

    Chuck Neal
    Expand Collapse
    Guest

    That worked perfectly! I've had some Access classes, but my brain is on
    vacation today. Thanks to John and Susan.

    "John Vinson" wrote:

    > On Tue, 13 Jun 2006 09:48:02 -0700, Chuck Neal
    > <ChuckNeal@discussions.microsoft.com> wrote:
    >
    > >Is there a way to do this?
    > >
    > >If Field One = X AND Field Two = Y, then replace Field One with Z.
    > >
    > >I assume it's some sort of update query.
    > >
    > >Any help would be appreciated.

    >
    > Create a new Query based on your Table.
    > Select Field One and Field Two. Put "X" on the Criteria line under
    > Field One, and "Y" on the Criteria line under Field Two. Open the
    > query in datasheet view to verify that you're selecting the desired
    > records, and only those.
    > Change the query to an Update query using the query type icon, or the
    > Query menu option.
    > Type "Z" on the Update To line under Field One.
    > Run the query by clicking the ! icon.
    >
    > John W. Vinson[MVP]
    >
     

Share This Page