2013-06-11 53 views
0

对坏的英语语法表示歉意:这是一本图书销售数据库,我在更新“库存”字段时出现了一些问题 - 书籍(book_id,价格,库存)表格 - “销售”表单中的值是“销售”形式中出售多少种图书(book_id,数量)的子形式。 请帮忙,谢谢带有子表单值的更新表

+0

好吧,所以你有一个表格“销售”和一个子表格称为“?”。你有什么问题?你如何填充子表单? – Grant

+0

你的英语比我的非英语好。 :o)但我仍然不明白你在问什么?你是否试图用书中销售表中的“qty”更新书籍表中的“库存”? –

+0

子表格称为“sale_details” - book_id,数量。例如“book1”的库存为100,“book2”为200,我从“book1”出售20,从“book2”出售10到“customer1”,那么我的库存就会变成这样:“book1”80和“ book2“是190 _ @milad moafi –

回答

1

更新时间:

如果要编辑的记录,你会做这样的事情:

'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 

让我知道如果这样的事情会帮助或者如果您需要我来更新它。

+0

我知道如何更新字段,添加一些记录,使用VBA执行SQL和...但我无法写入那SQL查询 - @milad Moafi –

+0

我的道歉,看到更新的代码。 – Grant

+0

谢谢@milad moafi –