当记录被删除时,会喜欢它进入DELETED TABLE [英] When a Record deleted, WOULD like it to go into a DELETED TABLE
问题描述
大家好吧
iv设计了一个数据库,当按下删除按钮时,它会完全删除记录,但我不想要它只是禁用分配器。
iv crreated,分配器表中的一列,并将禁用的sipensers放到NO或Y,我创建了一个禁用且未禁用的查询。
选择*掌柜
where allocatesers.disabled =" no"
或
select *分配器
其中allocsers.disabled =" Y"
所以我也有,但是在其他查询中这个sql,我是这样的只显示活动的分配器,但是当我去报告并点击privew时,PARAMETER BOX打开并要求DISPENSER.DISABLED,我在Y或NO,但它只是做同样的事情或错误,>
下面是推送预览按钮时的代码
Sub PreviewReport_Click()
On Error GoTo Err_Previe wReport_Click
Dim stRepName As String:Rem保存报告名称
Dim stDispId As String:Rem保留分配器ID
Dim stQuery As String:Rem持有查询名称
Dim stWhere As String:Rem持有where子句
Dim stExtra As String:
Dim stMonthYear ,stYear,stWeekCount As String
Dim intX As Integer,rst as Recordset
Dim dtEndDate As Date
stRepName = Form。 cbReports
如果IsNull(Form.cbDispenser)那么
MsgBox(请选择一个饮水机。)
GoTo Exit_PreviewReport_Click
结束如果
stDispId = Form.cbDispenser
stWhere =""
如果IsNull(Form.cbMonthYear)那么
MsgBox(请选择一个月)
GoTo Exit_PreviewReport_Click
Else
stMonthYear = Form.cbMonthYear
stYear =格式(CDate(" 1" &安培; Form.cbMonthYear),yyyy)
结束如果
dtEndDate = Nz(DMax(" EndDate"," Dispensers") ;,[ID] ="& stDispId),cLowDate)
如果stRepName =" Weekly Dispenser Sales"然后
stQuery =" Weekly Dispenser Sales"
ElseIf stRepName =" Individual Weekly Sales"然后:Rem Sheet 8
如果dtEndDate<> cLowDate和_
格式(dtEndDate," YYYYMMDD")<格式(CDate(cbMonthYear),YYYYMMDD)然后
MsgBox(本月没有此分配器的记录)
退出Sub
Else
stQuery =" Individual Weekly Sales"
stWhere =" SALES.DISPENSER_ID =" + stDispId +"和格式(START_DT,"" MMMM YYYY"")=""" + stMonthYear +"""和DISPENSERS.Disabled =" no"" """"""
结束如果
ElseIf stRepName =" Company Weekly Sales"然后
stQuery =" Company Weekly Sales"
stExtra =" AND DISPENSERS.Disabled ="" no""
stWhere =" MonthYear =""" + stMonthYear +"""" + stExtra
ElseIf stRepName =" Company Monthly Sales"然后
stQuery =" Company Monthly Sales"
ElseIf stRepName =" Company Year End"然后
stQuery =" Company Year End"
stWhere =" SALES.WorkingWeek = -1"
ElseIf stRepName =" Dispenser比较月刊然后:Rem Sheet 11
stQuery =" Dispenser Comparison Monthly"
stWhere =" MonthYear =""" + stMonthYear +""""
ElseIf stRepName =" Dispenser Comparison Yearly"然后
stQuery ="" Dispenser Comparison Yearly"
stWhere =" Year =" &安培; stYear& "和SALES.WorkingWeek = -1"
ElseIf stRepName =" Individual Monthly Sales"然后
如果dtEndDate<> cLowDate和_
格式(dtEndDate," YYYY")<格式(CDate(cbMonthYear),YYYY)然后
MsgBox(今年没有此分配器的记录)
退出Sub
Else
stQuery =" Individual Monthly Sales"
结束如果
ElseIf stRepName =" Individual Year End"那么
stQuery =" Individual Year End"
stWhere =" DISPENSERID =" &安培; stDispId& "和SALES.WorkingWeek = -1"
结束如果
DoCmd.OpenReport stRepName,acPreview,stQuery,stWhere
Exit_PreviewReport_Click:
退出Sub
Err_PreviewReport_Click:
MsgBox Err.Description
恢复Exit_PreviewReport_Click
End Sub
帮助我的朋友............... HEEEELLLLPPPP。我已经尝试将DISPENSER.DISABLED定义为stEXTRA,你可以看到,但我不知道如何编写语法,甚至我正确的做法。
Hi there everybody
iv designed a database, curently when the delete button is pushed, it deletes the record completly, but i dont want that i want it to just disable the dispenser.
iv crreated, a column in the dispenser table and put the disabled sipensers to NO or Y, i have created a disabled and NOT disabled query.
select * dispensers
where dispensers.disabled="no"
or
select * dispensers
where dispensers.disabled="Y".
so i have also, but this bit of sql in other queries, were i ws to just display the dispensers who are active, but when i go to a report and click privew, a PARAMETER BOX opens and asks for DISPENSER.DISABLED, i ut in Y or NO, but it just does the same thing or errors,
below is the code for when the preview button is pushed
Sub PreviewReport_Click()
On Error GoTo Err_PreviewReport_Click
Dim stRepName As String: Rem Holds the Report name
Dim stDispId As String: Rem Holds the Dispenser ID
Dim stQuery As String: Rem Holds the Query name
Dim stWhere As String: Rem Holds the where clause
Dim stExtra As String:
Dim stMonthYear, stYear, stWeekCount As String
Dim intX As Integer, rst As Recordset
Dim dtEndDate As Date
stRepName = Form.cbReports
If IsNull(Form.cbDispenser) Then
MsgBox ("Please pick a Dispenser.")
GoTo Exit_PreviewReport_Click
End If
stDispId = Form.cbDispenser
stWhere = ""
If IsNull(Form.cbMonthYear) Then
MsgBox ("Please pick a Month")
GoTo Exit_PreviewReport_Click
Else
stMonthYear = Form.cbMonthYear
stYear = Format(CDate("1 " & Form.cbMonthYear), "yyyy")
End If
dtEndDate = Nz(DMax("EndDate", "Dispensers", "[ID] = " & stDispId), cLowDate)
If stRepName = "Weekly Dispenser Sales" Then
stQuery = "Weekly Dispenser Sales"
stWhere = "format(START_DT,""MMMM YYYY"") = """ + stMonthYear + """"
ElseIf stRepName = "Individual Weekly Sales" Then: Rem Sheet 8
If dtEndDate <> cLowDate And _
Format(dtEndDate, "YYYYMMDD") < Format(CDate(cbMonthYear), "YYYYMMDD") Then
MsgBox ("There are no records for this Dispenser in this month")
Exit Sub
Else
stQuery = "Individual Weekly Sales"
stExtra = "DISPENSERS.Disabled = ""no"" "
stWhere = "SALES.DISPENSER_ID = " + stDispId + " and format(START_DT,""MMMM YYYY"") = """ + stMonthYear + """ and "DISPENSERS.Disabled = ""no"" """""""
End If
ElseIf stRepName = "Company Weekly Sales" Then
stQuery = "Company Weekly Sales"
stExtra = " AND DISPENSERS.Disabled = ""no"" "
stWhere = "MonthYear= """ + stMonthYear + """" + stExtra
ElseIf stRepName = "Company Monthly Sales" Then
stQuery = "Company Monthly Sales"
stWhere = "Year= " & stYear
ElseIf stRepName = "Company Year End" Then
stQuery = "Company Year End"
stWhere = "SALES.WorkingWeek=-1"
ElseIf stRepName = "Dispenser Comparison Monthly" Then: Rem Sheet 11
stQuery = "Dispenser Comparison Monthly"
stWhere = "MonthYear= """ + stMonthYear + """"
ElseIf stRepName = "Dispenser Comparison Yearly" Then
stQuery = "Dispenser Comparison Yearly"
stWhere = "Year= " & stYear & " and SALES.WorkingWeek =-1"
ElseIf stRepName = "Individual Monthly Sales" Then
If dtEndDate <> cLowDate And _
Format(dtEndDate, "YYYY") < Format(CDate(cbMonthYear), "YYYY") Then
MsgBox ("There are no records for this Dispenser in this year")
Exit Sub
Else
stQuery = "Individual Monthly Sales"
stWhere = "DISPENSER_ID=" & stDispId & " and Year = " & stYear
End If
ElseIf stRepName = "Individual Year End" Then
stQuery = "Individual Year End"
stWhere = "DISPENSERID=" & stDispId & " and SALES.WorkingWeek = -1"
End If
DoCmd.OpenReport stRepName, acPreview, stQuery, stWhere
Exit_PreviewReport_Click:
Exit Sub
Err_PreviewReport_Click:
MsgBox Err.Description
Resume Exit_PreviewReport_Click
End Sub
HELP ME GUYS...............HEEEELLLLPPPP. i have tried defining DISPENSER.DISABLED as stEXTRA as you can see, but im not sure how to write the syntax or even if im doing it right.
推荐答案
嘿伙计们,我有麻烦doign的东西
i有一个掌柜表,也有一个主菜单,菜单上有一个按钮,你可以修改掌柜,也删除它们。
但我没有删除会员,我希望将会员从分配器表中取出并将其分配到已删除的分配器表中,任何想法?
请帮助,我的大脑很慌乱。欢呼男孩和女孩。
Hey Guys, im having trouble doign something
i have a table of dispensers, also have a main menu, on the menu it has a button were you can amend dispensers, also delete them.
but instead of deleting the member, i would like it to take the member out of the dispenser table and inseart it into a deleted dispenser table, any ideas?
please help, my brain is rattled. cheers guys and girls.
使用追加查询将记录添加到删除按钮。表,然后删除记录!根据您的具体情况,您可以考虑在删除表中为删除日期添加一个字段。根据您是否只想要日期或日期和时间,将字段'的定义中的默认值设置为Now()或Date()。
Use an Append Query to add the record to the "Delete" table, then delete the record! Depending on your situation, you might consider adding a field to the Delete table for the deletion date. Set the Default Value in the field''s definition to Now() or Date() depending on whether you want just the date or date and time.
使用追加查询将记录添加到删除按钮表,然后删除记录!根据您的具体情况,您可以考虑在删除表中为删除日期添加一个字段。根据您是否只想要日期或日期和时间,将字段'的定义中的默认值设置为Now()或Date()。
Use an Append Query to add the record to the "Delete" table, then delete the record! Depending on your situation, you might consider adding a field to the Delete table for the deletion date. Set the Default Value in the field''s definition to Now() or Date() depending on whether you want just the date or date and time.
大声笑,这有点超出我的想象:( :(,我对这一切都很新,只是真的想要将分配器从分配器表移到dispsenser删除表时删除单击。
lol thats a bit over my head:(:(, im new to all this, just really want the dispense moved from the dispenser table to dispsenser deleted table when delete is clicked.
这篇关于当记录被删除时,会喜欢它进入DELETED TABLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!