Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to populate a new column and set as key using VBA?

I have a macro that, when run, performs the following operations:
a) Empties out an existing table
b) Uses Application.ImportXML to pull in new data from an XML file
c) Uses the following SQL to add a new column

DoCmd.RunSQL "ALTER TABLE sampling ADD COLUMN PartStep TEXT;"

d) Here's where I'm stuck. I now want to popuate the new column PartStep by concatenating the existing columns Part and Step from the data I just imported.
e) I then want to make column PartStep into the primary key.

Can anyone please help? How do I use VBA to perform d&e? Thank you in advance.

Comments

  • dokken2dokken2 Member Posts: 532
    : I have a macro that, when run, performs the following operations:
    : a) Empties out an existing table
    : b) Uses Application.ImportXML to pull in new data from an XML file
    : c) Uses the following SQL to add a new column
    :
    : DoCmd.RunSQL "ALTER TABLE sampling ADD COLUMN PartStep TEXT;"
    :
    : d) Here's where I'm stuck. I now want to popuate the new column
    : PartStep by concatenating the existing columns Part and Step from
    : the data I just imported.
    : e) I then want to make column PartStep into the primary key.
    :
    : Can anyone please help? How do I use VBA to perform d&e? Thank you
    : in advance.
    :

    you can do with an update query-

    docmd.runsql "UPDATE sampling SET sampling.PartStep = [part] & [step];"
Sign In or Register to comment.