从表单/子表单写入表 [英] Writing from form/sub-form to a table
问题描述
我有一个表格(采购订单)和一个子表格(采购订单明细)。主表单包含PO编号(文本框),供应商(组合框),员工(组合框),状态(组合框),其中包含2条记录(新建和完成)和一个日期框(当PO时)被创造了)。子表单(数据表)包含产品(组合框),数量和价格字段。
我想要做的是在主表单上添加一个按钮接下来。
按下按钮时,应执行VBA代码并执行下一步操作。从主表单(采购订单编号,状态和日期)和子表单(产品,数量和价格)中获取数据,并将所有数据放入表格(StockMovements)。
我设法使用下一个代码:
I have a form (Purchase Orders) and a sub-form in it (Purchase Order Details). The Main form contains Number of the PO (text box), Supplier (combo-box), Employee (combo-box), Status (combo-box) which contains 2 records (New and Done) and a date box (when the PO was created). The Sub-form (datasheet) contains Product (combo-box), Quantity and a Price field.
What I want to do is to add a button on the main form which will do next.
When the button is pressed a VBA code should be executed and do next. Take data from the Main form (Number of the PO, Status and the date) and the Sub-form (Product, Quantity and Price) and put all that into a table (StockMovements).
I managed to do that with the next code:
推荐答案
您的采购订单和采购订单详细信息表格绑定到表格或查询还是未绑定?
Are your Purchase Orders and Purchase Order Details Forms Bound to a Table or Query or are they Unbound?
是,它们是表格。
您可能想要试试像这样的东西广告。代码是徒手创建的,如果没有你调整它并使其适合您的环境,它将无法工作:
You''ll probably want to try something like this instead. The code was created freehand and will not work without you tweaking it and getting it right for your environment:
这篇关于从表单/子表单写入表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!