Welcome to SPN

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

Sign Up Now!
  1. Monthly (Recurring) Target: $300 :: Achieved: $95
      Become a Supporter    ::   Make a Contribution   

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]
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page