Forum Discussion

turniporangementions's avatar
turniporangementions
Copper Contributor
Apr 02, 2022

Update query to change data in a table

Table A has: HorseID (Number), HorseName (text)
Table B has: HorseID (Number), HorseName (text)

I want to update Table B HorseName to be the same as Table A Horsename, the HorseID would be the same, Table B has old names that have been change manually in table A

Thanks' for any help ....Bob

  • George_Hepworth's avatar
    George_Hepworth
    Silver Contributor

    turniporangementions 

     

    Step one: Make back up copies of both tables, just in case.

    Step two: make a back up copy of the accdb, just in case.

    I wish I could use the real table names, but the Update query would be similar to this:

     

    UPDATE TableB

    INNER JOIN TableA ON TableB.HorseID = TableA.HorseID

    SET [TableB].[HorseName] = [TableA].[Horsename];

     

    I

  • I've got this far
    UPDATE tblHorseInfo INNER JOIN tblInvoice ON tblHorseInfo.HorseID = tblInvoice.HorseID SET
    WHERE (((tblHorseInfo.HorseName)<>""));
    • arnel_gp's avatar
      arnel_gp
      Steel Contributor
      this will Never happen:

      tblHorseInfo.HorseName)<>""

      when you left the field blank (or fill it with just spaces, access remove them), access will put Null to it.

      you can either use:

      Where Not (tblHorseInf.HorseName Is Null)

      or

      Where Len((tblHorseInf.HorseName & "") <> 0
      • turniporangementions's avatar
        turniporangementions
        Copper Contributor
        Thanks for the help, I am getting a syntax error on "="
        UPDATE [tblInvoice].[HorseName] = [tblHorseInfo].[Horsename];
        SET WHERE (((tblHorseInfo.HorseName)<>""));
        Regards Bob

Resources