且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MS Access创建新的订单和订单行

更新时间:2023-11-20 14:23:52

创建子表单时,必须指定父表单和子表单之间的关系.与您为表创建的关系相同.然后只有Access会为您过滤记录.

When you create a sub-form you have to specify the relationship between the parent and sub-form. the same relationship you have created for your tables. Then only Access will filter the records for you.

关于您的问题.您应该在[订单]表中创建一个新的[订单]记录,您将在其中输入/选择[customer_id,staff_id,订单明细等]

Regarding your question. You should create a new [order] record in [order] table where you will be entering/selecting [customer_id, staff_id, order details ect]

一个订单可以有多个项目,因此您的[order_items]表(我假设订单行是您用于此表的术语)存在

one order can have more than one items so your [order_items] table (i assume orderline is the term you use for this table) exists of

  • order_id
  • product_id(order_id,product_id复合键)
  • 数量
  • 价格
  • 等.

现在,当您要开始接受订单时,需要创建一个绑定到tbl_order的新表单.在frm_order中,您将有一个子源,该子源已绑定到tbl_oder_items(在您的情况下是订单行)

Now when you want to start taking order you need to create a new form that is bound to tbl_order. In the frm_order you will have a sub-from which is bound to tbl_oder_items (in your case orderline)

frm_order和frm_oder_items应该有关系.通常,当您拖动表以创建子窗体时,ACCESS会要求设置关系.如果您手动创建子表单:

The frm_order and frm_oder_items should be have a relationship. usually when you drag the table to create the subform ACCESS will ask to set the relationship. if you create the subform manually:

  • 选择子表单
  • 转到属性表
  • 选择链接主字段:order_id
  • 选择链接子字段:order_id

现在,当您打开frm_order时,它将显示tbl_order_items表中的所有记录(换言之,该订单在其列表中包含的所有产品).

Now when you open the frm_order it will show all the records (in other words all the products the order has in its list) from the tbl_order_items table.

您的tbl_order_item/orderline表还通过product_id字段引用了产品表.

Your tbl_order_item /orderline table also referencing to the product table via the product_id field.

在frm_order_items中插入一个组合框,并将其绑定到product_id.组合框的行来源将是

Insert a combobox in the frm_order_items and bound it to the product_id. The combobox's rowsource would be

select product_id, product_name from tbl_product

将出现此错误消息: '您请求对表进行的更改未成功,因为它们会在索引,主键或关系中创建重复的值.更改包含重复数据的一个或多个字段中的数据,删除索引,或重新定义索引以允许重复输入,然后重试'

当您尝试为同一订单两次添加产品时.相反,您应该增加产品的数量.

when you try to add a product twice for the same order. instead you should increase the quantity for the product.

尝试一下,让我们知道它的进展.

Try this and let us know how it went.