Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access 使用子窗体值更新表_Ms Access - Fatal编程技术网

Ms access 使用子窗体值更新表

Ms access 使用子窗体值更新表,ms-access,Ms Access,为糟糕的英语语法道歉:这是一个图书销售数据库,我在更新“库存”字段时遇到一些问题-从图书(图书id,价格,库存)表-销售表单中的值,销售表单中有一个子表单关于一种图书的销售量(图书id,数量)。 请帮助,谢谢更新: 如果要编辑记录,请执行以下操作: 'this will create the recordset variable and a string variable Dim myR As Recordset Dim strSQL as String 'to find the re

为糟糕的英语语法道歉:这是一个图书销售数据库,我在更新“库存”字段时遇到一些问题-从图书(图书id,价格,库存)表-销售表单中的值,销售表单中有一个子表单关于一种图书的销售量(图书id,数量)。 请帮助,谢谢更新:

如果要编辑记录,请执行以下操作:

'this will create the recordset variable and a string variable
Dim myR As Recordset
Dim strSQL as String    

'to find the record you want to edit use this and then set your recordset to this query
strSQL = "Select * From Books Where book_id = '" & Me.Book_I_Want_To_Edit_Field & "'"

'make the table strSQL your table to work with
Set myR = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)


'you can set your subform fields or controls here
Me.Sales_Details.Form.Field_in_subform_to_edit = MyR![Inventory]

'you need this to edit it
myR.Edit

'Modify everything here with vba

'then update it
myR.Update

'clear the variable
Set myR = Nothing

让我知道这样做是否有帮助,或者您是否需要我更新它。

好的,您有一个“销售”表单和一个名为“?”的子表单。你有什么问题?您是如何填充子窗体的?您的英语比我的非英语好:o) 但我还是不明白你在问什么?您是否试图用已售出图书表中的“数量”更新图书表中的“库存”?称为“销售详情”的子表单-图书id,数量。例如,“book1”的库存是100,“book2”是200,我从“book1”卖了20个,从“book2”卖了10个给“customer1”,那么我的库存将是这样的:“book1”80和“book2”是190,这是可行的,但是你想每次都用一个连续的总数添加一个新记录吗?或者您想为每本书保留一条记录并每次修改/编辑该记录吗?想为每本书保留一条记录并每次修改/编辑该记录@Mild Moafi我知道如何更新字段、添加一些记录、执行SQL和。。。使用VBA,但我无法编写SQL查询-@milad Moafi