【问题标题】:Excel to Access, change data types as part of a button's on click actionExcel to Access,将数据类型更改为按钮单击操作的一部分
【发布时间】:2025-12-20 20:35:11
【问题描述】:

我每天两次在 SAP 中运行 2 份报告(我只有用户级权限),需要在 Access 中结束。当前流程如下所示:

(1) Run report one, select the fields I need, export to Excel.
(2) Run a saved import within Access to get the table.
(3) Switch that table to design view so I can edit the data types to sync with the table I intend to update.
(4) Run an append query. 
(5) Rinse and repeat for report 2.

由于我希望将此任务委托给用户,因此我想要一个将流程更改为的按钮:

(1) Run report one, select the fields I need, export to Excel.
(2) Click the "import, change data type and append" button. 
(3) Rinse and repeat for report 2.

Excel 文档的格式如下所示:

txtField1 txtField2 txtField3 txtField4 txtField5 DateAndTimeField1

它还使用与 Access 不同的命名约定。

访问需求:

TxtField1 txtField2 NumberField1 NumberField2 NumberField3 DateAndTimeField1

我可以使用macro 将 Excel 文档导入 Access,然后只需将附加查询添加到按钮的操作即可。但除非数据类型同步,否则我无法将其附加到我想要的表中。

如何在按钮的单击操作中切换导入文档上的数据类型和(如果使用 vba)列标题?

【问题讨论】:

    标签: sql excel vba ms-access ms-access-2010


    【解决方案1】:

    也许试试Range("A1").NumberFormat 或者,Range("D2").Value = Val(Range("C2").Value)Val() 函数。

    【讨论】: