删除子表单的查询 [英] Delete Query for subforms

查看:69
本文介绍了删除子表单的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次问好,


关于这个问题的背景情况有点长,对我来说很简单:


我有一个主表格frmTimesheets有4个子表单(subEmployeeHourLog,subInternalEquipmentHourLog,subRentalEquipmentHourLog和subDailyProduction)。

前3个子表单,用户输入EmpNumber或EquipNumber,当天有CostCode和HoursLogged。第二个子表单显示tblDailyQuantity(PK QuantityID)中的所有内容,其中qryTimesheetCostCodeDisplay查询上述3个子表单中输入的所有唯一CostCodes,并将其发送到由TimesheetID链接的tblDailyQuantities。


现在我已经设法创建了一个工作追加查询,只为每个相应的时间表发送不匹配的CostCodes,但是我不能让我的删除查询做同样的事情。目前它删除tblDailyQuantities中的每个不匹配的CostCode,因此从所有其他时间表中删除所有数量并仅保留显示/活动主表单中的数量。


我知道我的问题围绕在查询的SQL语言中同时使CostCode和TimesheetID匹配,但我在SQL中不够舒服。


下面是删除querry DqryUpdateQuantities背后的SQL(全部通过除了我添加的下划线语句之外的querry向导(如果该语句在SQL中甚至有意义),这个表达式的语法也不好):

Hello again,

The background scenario on this problem is a little long so bare with me:

I have a main form frmTimesheets with 4 subforms (subEmployeeHourLog, subInternalEquipmentHourLog, subRentalEquipmentHourLog and subDailyProduction).

The first 3 subforms, the user inputs either the EmpNumber or EquipNumber with a CostCode and HoursLogged for that day.

The 4th subform display everything in tblDailyQuantity (P.K. QuantityID) where essentially qryTimesheetCostCodeDisplay queries all the unique CostCodes inputed in the above 3 subforms and sends its to tblDailyQuantities linked by the TimesheetID.

Now I have managed to create a working append query sending only the unmatched CostCodes for each respective timesheets but I cannot get my delete query do to the same. At the moment it deletes every unmatching CostCodes in tblDailyQuantities, therefore deleting all the Quantities from all the other timesheets and keeping only the ones in the displayed/active mainform.

I know my problem revolves around getting both the CostCode and TimesheetID to match in the SQL language of the query but I am not comfortable enough in SQL.

Below is the SQL behind my delete querry DqryUpdateQuantities (All done through the querry wizard except for my added underline statement (if that statment even makes sense in SQL), not good with the syntax of this expression):

展开 | 选择 | | 行号

推荐答案

Beaudry93,


首先,你不能删除DELETE查询中的一个字段,你只能删除整个记录。因此,DELETE查询的第一行将不起作用。第一行应该是:

Beaudry93,

First, you cannot delete one field in a DELETE query, you can only delete the entire record. So, the first line of your DELETE query will not work. The First line should be:

展开 | 选择 | Wrap | 行号


现在有适当的语法匹配2个或更多标准只需要一个语句或者我必须编写多个IF语句吗?
Now is there a proper syntax to match 2 or more criterias in just one statement or would I have to write multiple IF statements?


也许最好的方法是编写一个单独的Query来识别你想要的QuantityID,我认为你到目前为止:

Perhaps the best way would be to write a separate Query that identifies your desired QuantityIDs, which I think you have that so far:

展开 | 选择 | Wrap | 行号


这篇关于删除子表单的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆