ACCESS VBA _vba The cross-database operation table

Source: Internet
Author: User
Tags db2 one table

The article was sorted after reading the online article.

Problem:

There is a db1.mdb with a table tbl1 with two field IDs and name.

There is also a db2.mdb, with one table tbl2, and two field IDs and name in the table.

Now you want to use the name of the TBL2 in DB2 to update the name of the Tbl1 ID in DB1.
(For example, there is a list of workers, the number of workers and the names of workers, and now a group of workers, the worker's name is naturally updated.) Finance is a convenient way to update their payroll with this updated list of workers. The list of workers is DB1, and the payroll is DB2. )

The SQL statement writes this:

Strsql= "UPDATE tbl2 INNER JOIN [MS Access; pwd= password; database=db1.mdb full path].tbl1 as TMP1 on tmp1.id=tbl2.id SET tbl2.name=tmp1.name "

The extreme point can also be considered to write this:

Strsql= "UPDATE [MS Access; pwd= password; database=db2.mdb full path].tbl2 as TMP2 INNER JOIN [MS Access; pwd= password; database=db1.mdb full path].tbl1 as TMP1 on tmp1.id=tmp2.id SET tmp2.name=tmp1.name "

Obviously, [MS Access; pwd= passwords; database=db2.mdb full path].tbl2 and as Tmp1 are important.

After writing, you can use Docmd.runsql strSQL to execute.

Update, other actions can be written in accordance with.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.